Newbie to freeRTOS, so please be gentle with me?
I am using freeRTOS on an embedded project using NXP IMXRT microcontrollers (~ 550MHz Cortex M7) and I had a question about the recommended method for handling “fast” events - and by fast I mean anything in the range say 1 us to 100 us (us = microseconds).
So far, I am not using any freeRTOS kernel services but instead am using the MCU’s hardware timers to generate an interrupt every, say, 1 us. Then in the ISR all I do is modify a global variable (typically decrement it) and in the main code, write a new value to that global variable and then sit in a while() loop waiting for it to reach zero. However whilst this system seems to work OK, I am running into occasional issues where the code sometimes hangs in the while() loops (currently there is no timeout in the while() loops, in the future there will be). I suspect this might be due to atomicity issues when updating the global variable, but this is not yet proved.
So my broader questions is, what is the recommended method for doing this kind of thing in a freeRTOS environment? How do others typically do this?
thanks in advance!