2014-07-08 10:51 PM
For now, I need to do a simple benchmark of memcpy. Here, it's pseudocode.
#define SYSTICKS_REG 0xE000E018uint32_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 ?2014-07-09 01:40 AM
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).2014-07-09 10:37 AM
The SysTick counter is also only 24-bit, you'll have to manage that in your arithmetic.
Consider using DWT_CYCCNT