I’ve got a crit section in my app and I need a delay for a predetermined amount of time in this crit section (no way around it). RTOS API doesn’t work in a crit section so what’s the best solution for this? I was thinking about time.h functions
Also, on the same topic - how to measure runtime in the crit section. I also need to implement that.
Milliseconds. Maybe one of the ways is to exit crit section, call TaskDelay, let app run for a delay then calling crit section again and continuing the executing of the func?
taskENTER_CRITICAL();
... code part 1
taskENTER_CRITICAL();
vTaskDelay(10); // Run delay
taskENTER_CRITICAL();
... code part 2
taskENTER_CRITICAL();
Maybe, or maybe your don’t really want a critical section but use a mutex to protect the resource.
The key thing is that critical sections are usually SHORT sections of code where either you need to protect something from an ISR, or a short enough that the quickness of the critical section over other forms of protection makes it useful. If you really need to protect something from an ISR for that long, disable the needed interrupt.
Disabled interrupts using NVIC_DisableIRQ(Although it’s better to use register mask) and implemented TaskDleays. Runs good so far.
Thanks for a push in a right direction.