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?