cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the precise time of the consumption function by using SYSTICK timer?

gapryun
Associate II
Posted on August 21, 2014 at 02:53

As far as I knew, SYSTICK Timer is a 24-bit down counter. For now, I need to know the precise consumption time for the memcpy function. Suppose I set SysTick->RELOAD = 511, it will turn out two cases as the following description. 

Define:

1. One cycle means 511 to 0 must be finish.

2. Two or more cycles mean 511 to 0, 511 to 0, ... , 511 to 0, 511 to i, i in [0, 511].

Case 1: Offset is small or normal, so the memcpy will finish in one cycles.

Case 2: Offset is very big, e.g. 16K. So the memcpy will finish in two or more cycles.

How do I get the ''cycles'' ?

#systick
4 REPLIES 4
Posted on August 21, 2014 at 04:27

It's 24-bit, but you have foreshortened it to 9-bit, suggest you either extent the wrapping point, ideally to a maximal value or just use a 32-bit free running timer like DWT_CYCCNT, where you know it's running at the core clock frequency, runs for close to a minute at 72 MHz and the math is trivial.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Andrew Neil
Evangelist III
Posted on August 21, 2014 at 09:02

''Suppose I set SysTick->RELOAD = 511''

As clive1 says, why do that?

Why choose such a small value - why deliberately make the wrap-around such a big issue?

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka8713.html

If you envisage that the operation will still take longer than one ''cycle'', then enable the SysTick interrupt, and have the handler count the ''cycles''...

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka8713.html

http://www.keil.com/pack/doc/cmsis/Core/html/group___sys_tick__gr.html

gapryun
Associate II
Posted on August 21, 2014 at 15:09

If I define it equals MAX, e.g. 65536, how does it guarantee that will not turn out two or more cycles?

Posted on August 21, 2014 at 18:02

Well presumably you could count SysTick interrupts?

The 24-bit maximal would be 16777215 wouldn't it. 2^24-1
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..