richard_damon wrote on Friday, May 04, 2012:
An ISR taking too long won’t “break” the RTOS in the sense of it crashing or something like that. It may well “break” your program in that it no longer meets your real time requirements. Interrupts taking so long that you might miss a timer tick interrupt will cause your program’s sense of time to be disturbed, more time has really passed than the program knows about.
Interrupts, by their nature are limited in their flexability to schedule their control routines, They may have a nesting, but they can’t “defer” and then resume like a task. Tasks on the other hand are very flexible in execution control.
When NOT using an OS, the ISR needs to do everything needed to service the device, as it has no other way to get something to execute. When using an OS that isn’t an RTOS, it might be able to hand off “low priority” operations to a task, but the hallmark of a RTOS is that you can setup a “real time” task to get high priority work done on time.
With an RTOS, you typically do very little in the ISR, normally not more than (maybe) grabbing the data and clearing the interrupt, and any more complicated work is left for a task. Think of it as the ISR handles things that need to be done in microseconds, while the task handles stuff that is more on the order of milliseconds, or so. There isn’t THAT much of a cost in time to transition to the task to process, as if that task is the highest priority available, it should run as soon as the ISR exits.
For this to work this way, the Interrupt should NOT be “above the max set for FreeRTOS”, as such an interrupt WILL need to interact with FreeRTOS. The only real reason I can think of to have an interrupt above the FreeRTOS max level is something that handles activity that REALLY needs microsecond level response or you get failure, so the interrupt can’t be temporarily masked for some FreeRTOS operations in critical sections. FreeRTOS has been designed with the goal of these periods being as short as possible (and of a knowable limited length). Having this type of routine around normally requires very definite care and planning.