2021-11-06 03:39 AM
Can someone tell me when I use
uint16_t temp;
temp = __HAL_TIM_GET_COUNTER(&htim2);
the above why temp doesn't equal the TIM2 CNT register in the debugger? I've also tried
temp = htim2.Instance->CNT;
Solved! Go to Solution.
2021-11-06 10:33 AM
This is a normal peripheral register bit.
Maybe there's some setting to set these bits from inside the debugger, I don't know what debugger are you using.
JW
2021-11-06 03:43 AM
> the above why temp doesn't equal the TIM2 CNT register in the debugger?
TIM2 running? temp was read out from TIM2 in a different time than when debugger read out TIM2_CNT register.
JW
2021-11-06 06:14 AM
Timers continue to run when execution is paused in the debugger by default. You can adjust that behavior in the DBGMCU freeze register settings.
2021-11-06 08:22 AM
> Timers continue to run when execution is paused in the debugger by default. You can adjust that behavior in the DBGMCU freeze register settings.
Even then, and even if you single-step, executing code which reads out TIMx_CNT may/will happen while the timer is running between steps, whereas the debugger reads it afterwards, so the values may/will differ.
JW
2021-11-06 09:32 AM
being new to this tool suite can you point me to DBGMCU freeze settings location.....Somewhere under Properties- Run/Debug Settings?
2021-11-06 10:33 AM
This is a normal peripheral register bit.
Maybe there's some setting to set these bits from inside the debugger, I don't know what debugger are you using.
JW
2021-11-06 11:22 AM
Oh you are suggesting it is a bit in a register on the target? I thought it was a switch somewhere in the CubeMX IDE...
I am using a STLINK V3 SET
2021-11-06 11:24 AM
2021-11-06 11:26 AM
Got it:thumbs_up:...will give it a try...
Thanks to all for the help