2019-01-14 12:35 PM
I am trying to find time it takes for a loop, am I missing something ?
uint32_t time1 = HAL_GetTick();
...
unit32_t time= HAL_GetTick( ) - time1;
I am using Keil when I add time to watch list I am getting response cannot evaluate.
It does not show anything
Any help with the code, am i missing something, do I need to declare, initialize something first ?
2019-01-14 01:10 PM
to avoid compiler to remove code, declare time1 and time as volatile uint32_t
If the result of the calculation is not used, the compiler will remove the code...
2019-01-14 02:07 PM
I am not sure if I got your answer right but I did this
time = HAL_GetTick();
for (int i=0; i<100000000; i++)
{ i2cData[0]=0;
}
time1 = HAL_GetTick();
time2 = time1 - time;
and it seams to be working I get time2 = 2778 (in watch in Keil)
my board is 180 Mhz. Any idea ho to translate it into microseconds or milliseconds ?
2019-01-14 02:17 PM
If I understand what you're asking, the HAL_GetTick() function returns a counter that is incremented by the SysTick, which in a default CubeMX project is 1000Hz, (each tick is 1ms).
2019-01-14 02:35 PM
volatile uint32_t time_ms, time1_ms, time2_ms; // to be sure
If you put in the variable name the unit and scale (if present), the answer is obvious...
2019-01-14 03:14 PM
SysTick_Handler() normally calls HAL_IncTick() to advance the count, but requires that the SysTick has higher priority than interrupt/callbacks that might have reliance on it actually advancing.
2019-01-14 04:05 PM
It looks like the old Keil bug. The debugger does not like non-local variables, even declared volatile.
So I have to note the variable's addresses and later use memory views.
Complained several times... but they treat debugger enhancement requests like ST treats Cube bugs here.
-- pa