Skip to main content
gapryun
Associate II
August 21, 2014
Question

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

  • August 21, 2014
  • 4 replies
  • 1093 views
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
This topic has been closed for replies.

4 replies

Tesla DeLorean
Guru
August 21, 2014
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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
Andrew Neil
Super User
August 21, 2014
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

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
gapryun
gapryunAuthor
Associate II
August 21, 2014
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?

Tesla DeLorean
Guru
August 21, 2014
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 (See Profile) Up vote any posts that you find helpful, it shows what's working..