Keep system responsive with long control interrupt
Posted: Tue Apr 07, 2015 8:03 am
Hi All,
i recently ran into a Problem. In my Application i have an control function with an execution time of approx 30µs on stm32f4. This function needs to run every 50µs.
My first architecture was to use a high prio task for this triggerd by the ADC via binary semaphore. This prevents low Prio serial communication from getting timeout with my PC programm controling the device. Because uart interrupts can be served when control is calculating.
Now i had the idea of saving the 2 task stwiches to and from the controltask every 50µs. From the interrupt to the start of task execution there are 1 - 2µs delay. This ist quite fast for an RTOS, this is why i choosed Chibi, but i want to port the application to STM32F3 with the control runnig from CCM i can get this running at 12kHz but i need to save the task switches.
My thought is to trigger an Softwareinterrupt from the high ADC interrupt. And calulate the control function in this interrupt. So i can set uart int to higher Prio than the Software interrupt and have normal serial communcation. The Os then handles all low Prio stuff.
So i think i have only the nested interrupt switching instead of an hole task switch.
Or am i totaly wrong with this approach?
@edit: an other idea i just had, is to set the ADC int to lowest Prio. and Run the Control function directly from this int. so all other ints can get served by the controller and i can use os funktions to inform low prio threads of important things from the int. but i have no task switching delay. only small interruptions by the higher prio interrupts. With big DMA buffers for Uart this impact could be very small.
Any other ideas?
i recently ran into a Problem. In my Application i have an control function with an execution time of approx 30µs on stm32f4. This function needs to run every 50µs.
My first architecture was to use a high prio task for this triggerd by the ADC via binary semaphore. This prevents low Prio serial communication from getting timeout with my PC programm controling the device. Because uart interrupts can be served when control is calculating.
Now i had the idea of saving the 2 task stwiches to and from the controltask every 50µs. From the interrupt to the start of task execution there are 1 - 2µs delay. This ist quite fast for an RTOS, this is why i choosed Chibi, but i want to port the application to STM32F3 with the control runnig from CCM i can get this running at 12kHz but i need to save the task switches.
My thought is to trigger an Softwareinterrupt from the high ADC interrupt. And calulate the control function in this interrupt. So i can set uart int to higher Prio than the Software interrupt and have normal serial communcation. The Os then handles all low Prio stuff.
So i think i have only the nested interrupt switching instead of an hole task switch.
Or am i totaly wrong with this approach?
@edit: an other idea i just had, is to set the ADC int to lowest Prio. and Run the Control function directly from this int. so all other ints can get served by the controller and i can use os funktions to inform low prio threads of important things from the int. but i have no task switching delay. only small interruptions by the higher prio interrupts. With big DMA buffers for Uart this impact could be very small.
Any other ideas?