Olin Lathrop wrote: > > > What's the best strategy for dealing with updating > > a 10-bit PWM value asynchronously with TMR2? > > > > It looks like you could get a glitch if the update > > happens to occur just as TMR2 is overflowing. > > I've thought about this too. In the end I just updated the high 8 bits, > then the low two bits as quickly as possible thereafter. Since PWM is > usually used to achieve an average duty cycle over a longer time interval > than the PWM frequency, I think you can just ignore the glitch because the > average will still be correct. Yeah, I know, I'd feel better too if all 10 > bits were properly double buffered in the hardware. I poll timer2 and only change the registers in a time when the change will not affect the PWM output. Most of my apps use some type of polling to get the best hardware performance, and I also like to synchronise timer1 or timer2 a few insts after timer0 which I use for the main int, as I can then handle timer1/timer2 overflow issues at the end of the timer0 int, before any code processing gets to take place. Hope that makes sense. :o) -Roman -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads