I am controlling a robotic system using a dspic33E. I have a few PID control loops for motor control, several SPI slaves, and an I2C master that I communicate with. Currently, I use interrupts for setting flags which I then address in a tasks loop.

However, I am now starting to add in some orientation filtering/fusion which takes a few milliseconds to compute. This is unacceptable for my motor controllers and communication channels, so I was thinking about moving all of the computation related to those modules (motor control, SPI, I2C) into their respective ISR's (instead of setting flags, addressing them in the tasks loop).

The dsPIC33E has 7 interrupt priorities, so I can effectively structure the interrupts so that the higher priority timings are met, and then just do the orientation filtering/fusion in my tasks loop and have it be interrupted when needed.

This seems like a good structure to me, however I've been taught not to spend too much time in ISR's. Does the ISR priority structure effectively mitigate any issues I would run into with this? Is this a bad idea? Or are there just some things I need to look out for?


1 Answer 1


A great article on this approach is Build a super simple Tasker.

I have implemented this on dsPIC33e mcu's.

The biggest issue I faced was priority inversions that came from me trying to share information between tasks with global variables. Once I started using the typical IPC techniques to move information between tasks,it all worked well.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.