AVR Timer for PWM and interrupt

avrinterruptspwmstepper motortimer

I am developing a system that needs to drive 4 stepper motors through 4 dual H-bridges, for each phase of movement the AVR will receive SPI messages stating how many steps each motor should do and what delay should be between each step for each motor. The delays will all rounded to multiples of 100 micro seconds so I plan on using the interrupt of a timer set to as close to 100 micro seconds as it can get to count the time passing between the stepping of each motor as to determine when a step function should be executed. The thing is, I also need 4 PWM outputs to "chop" the power supply going to these steppers as to not overtax them.

Now my problem is that I am thinking about using the ATmega8535(L) for this task and it seems to indeed have 4 PWM outputs operating from 3 timers (it seems as if one of them has 2 channels). Now my question is, would I still be able to use the interrupt of one of the timers to drive my stepping functions?

Best Answer

You should be fine. If a timer is being used for PWM it should also be useable to generate interrupts. Also, you should be able to use one timer for more than one PWM output. I mean, if they design the chip with 4 PWM outputs and 3 timers, there has to be a way to actually use all 4 PWM outputs.