Another approach you might consider is to use a timer as a one shot pulse generator and reset it periodically based upon some other timer (i.e. the system timer) the OCx register is set to “clear on match”, so you r register, then set “Set on match” and then “force match”, read the timer, add your pulse width poke that out to the OCx, finally then set back to “clear on match”.
Also if you want to see how to use that technique to get 8 r/c pulse outputs from two pins, look at:
http://www.barello.net/Papers/AVR%20RC%20output.pdf
-----------
Larry Barello
www.barello.net
From: AVR-Chat@yahoogroups.com
[mailto:AVR-Chat@yahoogroups.com] On Behalf
Of Martin Jay McKee
Sent: Friday, November 11, 2005
8:06 PM
To: AVR-Chat@yahoogroups.com
Subject: RE: [AVR-Chat] Phase and
Frequency Correct PWM on a Mega 8
Yes, the I/O direction pins are set. Actually since this is part of a large project I’m going to press ahead with something else and assume that I get it right sooner or later. Perhaps when I come back to it I’ll have better luck.
Martin Jay McKee