We’re using FreeRTOS on an Infineon AURIX TC3xx (TriCore) device. Our application has periodic tasks running at 5ms, 10ms, and 20ms, and we also perform PFLASH memory operations (erase/write) from a task.
Here’s the issue we’re seeing:
After a PFLASH operation (e.g., eraseMultipleSectors()), the FreeRTOS xTickCount stops updating.
All periodic tasks that depend on vTaskDelay() or vTaskDelayUntil() also halt.
However, the Idle Task continues to run, which means the system is not entirely stalled.
After approximately 40 seconds, the tick and periodic tasks resume automatically.
We observed that STM0_TIM0 (system timer) reaches 0x10000000 right before the system resumes.
During flash operations with interrupts disabled, FreeRTOS’s time effectively pauses since it relies on tick interrupt. However, once you re-enable interrupts, the tick interrupt should start firing and FreeRTOS should continue normal task scheduling.
Does this 40 seconds time include flash operations for which interrupts are disabled?
This is specific to the Infineon hardware and therefore, I’d suggest reaching out to them for most accurate answers.
Maybe a better solution would be to ”fix” the tick timer ISR. With STM0 timer configured in compare mode, the ISR must make sure it sets the next compare value to a value in the future. Right now, your ISR is apparently not doing that. Before your fix, you were having to wait for the 32-bit timer to wrap all the way around. A 100 MHz clock on a 32-bit timer rolls over every ~43 seconds.
Another alternative is to configure the timer to reset its count value at each tick interrupt.
With either of those fixes, you’ll be able to tolerate long interrupt making no matter why you do it.
I’m assuming this code runs after you’re done with your long interrupt masking.
One problem with this approach is that the problem will return if you ever add anything else in the future that masks interrupts for longer than 1 msec. Same goes if you ever have a combination of interrupt handlers that happen to execute back to back for longer than 1 msec and block the STM0 ISR for longer than 1 msec.