Jinx wrote: >> Is it generally ok to have about 30 lines of code inside the interrupt >> routine? >> > > Stephen, hi, you can have as many lines of code as you like inside > an ISR. The only proviso is that, generally, if you are expecting > another interrupt, the current interrupt processing is finished. Or > at least left in a state that you can return to if, for example, a higher > priority or other interrupt/event needs processing first > > <> Thanks for the enlightenment! Most ISR info I see says to keep it as short as possible but, in my design, the only other thing going on aside from the code in the ISR is timer1's interrupt which is required for the delay. I am doing a hobby robot controller using 2 PWM channels for differential drive. Main routine calls a ramp up routine which increments both PDC registers to a preset max value using timer1 running to match the timer1 period reg and interrupt in between each increment. When one of the IR sensors sees and obstacle at a preset distance, it provides a switched logic level to INT0 or INT1 external interrupt pins (left or right sensor). My INT0 and INT1 ISR's will decrement one of the PDC regs with the same timer1 delay to provide a ramp down of the appropriate motor causing the bot to smoothly turn away from the obstacle until the external interrupt pin is no longer true. Then the same PDC reg is incremented back to where it originally was, again using the timer1 delay. At thins point, the ISR is done and returns control to the main loop. -- Regards, Stephen D. Barnes -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist