cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H745 - resetting of a variable in ISR does not work occasionally

Kurngop32
Associate III

I have a strange problem. I have a global uint32_t variable that counts up in the main loop and every 100 ms it gets reset in a timer-ISR. This works, but sometimes it does not.

Here is the value of the variable MainCounter read out by the debugger:

Kurngop32_1-1715256571202.png

The ISR is definitely called every time as the toggling variable test shows. Also inside the ISR MainCounter really is zero, I checked. But sometimes this zero does not "reach" the main loop.

Please help, I have absolutely no idea how this is even possible.

20 REPLIES 20

This has nothing to do with it being a dual core CPU. This problem exists one single core CPUs as well.

btw, I solved it now with a reset flag. This was the fastest solution.

if (ResetMainCounterFlag) {
	ResetMainCounterFlag = false;
	MainCounter = 0;
} else MainCounter++;