cancel
Showing results for 
Search instead for 
Did you mean: 

How do I get the Systick values from register in real-time ?

gapryun
Associate II
Posted on July 09, 2014 at 07:51

For now, I need to do a simple benchmark of memcpy. Here, it's pseudocode.

#define SYSTICKS_REG 0xE000E018

uint32_t *get_systicks (void)

{

    return (uint32_t *) SYSTICKS_REG;

}

measure_start = *get_systicks ();

for (int j = len; j <= i * len; j += len) {

    memcpy (test_dest + j, test_src, len);

}   

measure_end = *get_systicks (); 

Sometimes, (measure_end - measure_start) will be zero or a big number.

How can I debug it ?
2 REPLIES 2
chen
Associate II
Posted on July 09, 2014 at 10:40

Hi

The root of your problem lies in the fact that you do not understand what the 'SysTick' is.

SysTick is a regular 'heartbeat' for the system. The value (number of times a second) must be set by the system/programmer.

It is implemented in hardware by a timer peripheral.

The timer peripheral works by counting clock pulses, up/down to a threshold value. When the threshold value is reached - that is 1 'tick'. The counter is cleared on reaching the threshold.

It normally triggers an Interrupt (IRQ).

There must be an Interrupt Serviec Routine (ISR). The ISR must do something.

What you have done is to read the timer count of the SysTick timer peripheral. What this value means to the program is indeterminate!

''For now, I need to do a simple benchmark of memcpy.''

BTW - there are other ways to measure routine timing :

typically, you instrument the code by setting an IO pin on entry and clearing it on exit.

You can then very accurately measure on an oscilloscope the timing in REAL time.

If you do in in software - you rely on the processor itself being very accurate in timing. Since it is based on the xtal (or internal RC oscillator) - it is not that good (relatively).

Posted on July 09, 2014 at 19:37

The SysTick counter is also only 24-bit, you'll have to manage that in your arithmetic.

Consider using DWT_CYCCNT
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..