Announcements
Community Announcement : Welcome to the NEW Cypress Developer Community.
cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4

ShVy_264716
New Contributor II

Hi All

   

I am working in a direction to use SysTick timer in order to record a time period in between two events and save it in a variable. SysTick Timer has not any dedicated API to get time period from it. Can anybody please guide me to resolve this?

0 Likes
3 Replies
Bob_Marlowe
Expert II

The answer is "CySysTickGetValue()". Have a look into "System Reference Guide", Boot Component 5.20. There are all the APIs for the SysTick timer.

   

 

   

Bob

0 Likes
EvPa_264126
Valued Contributor II

Maybe you are interested in a component of meh for PSoC4 and PSoC 5LP :     SysTimers component

0 Likes
odissey1
Honored Contributor II

Shaunak,

   

This is example of using SysTick timer on PSoC4 and 5 to measure number of CPU cycles. Limit is 2^24 CPU ticks (about 0.7sec @24MHz CPU speed), as SysTick counter on Cortex M0 and M3 can not go beyond SYSTICK_MAXVAL:

   

#define SYSTICK_MAXVAL 0x00FFFFFF //max allowed SysTick counter value for 24bit
uint32 SysCntVal; // The value of SysTick counter you are trying to retrieve

   

SysTick_Config(SYSTICK_MAXVAL); //reset counter set to max value, 1-time, will not reload

   

//do some operations here..

   

SysCntVal = SYSTICK_MAXVAL - (SysTick->VAL); //get elapsed ticks (min offset 3 ticks)

   

sprintf(strMsg, "%d\r\n", SysCntVal); //report result
UART_PutString(strMsg);

   

 

   

Note that SysTick counter will not reload this way (it will quietly expires). It is possible to roll over 2^24 cpunts by enabling SysTick interrupt and resetting the timer, but doing this accumulates errors

0 Likes