For a project, I am using the m16/32 16 bit timer1. The current code works fine, but I have output control on OC1A and B turned off. I manage the pins manually. I wanted to switch the code to let the AVR manage the pin states, but I got nowhere last night. I'll relate the code:
I set up the timer for free running, non-PWM mode, count to ffff, 8MHz clock/1
I turn on ICR INT
Set OC pins to outputs, and bring high
When ICR fires, I set OC1A and B to be 512 cycles ahead of TCNT1. I also bring outputs low and turn on OC INTs. FInally, I set output control of each pin to be set-on-match
When each OC INT fires, I turn off output-control for that pin.
The idea is to reduce the jitter of the output signal by using the ICP, but reduce it further by letting the hardware bring the lines high when the compare is matched. Right now, with manual code, I have a problem if both channels are at the same value, as I can't be in both ISR routines at the same time, and my ISR routine (2 lines of C code) takes 36 cycles or so, which is too much error for this application.
However, when i run the above code, I see on my scope that the code works fine until the output-control is turned off. FOr some reason, (I've tried both toggle-mode and set-on-match), the pin makes a momemtary dip to ground, then returns to high.
Anyone have experience with turning off output control on timer outputs while the clock is running and having success?