Hi Josh, You can put the counterupdates in the interrupt routine if u want to control the PWM freq. independently from your mainloop. First of all I'd like to present a way to think about how it works: Think of it as 2 cam-wheels (like in a washing machine) One wheel sets the PWM output to 0 once each turn. The other one sets the PWM output to 1 once each turn. Now if these two wheels were on the same axle, and u start turning the axle around... the axle rpm decides the PWM-freq. And the phase-difference between the wheels decides the pulsefactor 0-100%. So it is perfectly okay that the counters roll over, they are supposed to ! You do not need to reload the counters unless u want to change the pulsefactor. And then all you do is add say 1 to the PWM- counter and the phase will shift slightly. Above method is dead simple and works like a charm, the routine below is more complicated and doesnt offer anything extra (i think) *ducks* I prolly could dig up some code I wrote using above techinqe for a recent project if ure interested... for the 877 tho. I figured id put it on piclist.com but no time to mess w that now :-) ----- Original Message ----- From: "Josh Koffman" > I am looking to use the code at > http://www.dattalo.com/technical/software/pic/pwm8.asm > to do multiple PWMs on one chip. My basic question is...where and when > do I update the PWM counters? I plan on putting the timer checking and > updating in an ISR, and triggering it with a TMR0 interrupt. This will > work on the first iteration, but once a counter has hit zero, doesn't it > just start again at 255? Therefore, I would need to reload the value I > want in the counter so that it will start to count down again. What if > after: > DECFSZ pwm0,F ;If the first counter has not reached 0 > IORLW 00000001b ;then we don't want to turn it off. > I add something to the effect of: > check pwm0 for zero > if zero, reload pwm0 with proper value -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.