Lost Timer1 overflow interrupts
Posted: Tue Aug 30, 2011 8:44 pm
In a project, Timer1 runs with 50 kHz (I cannot go lower for hardware reasons). The timer is used for PWM purposes and (via the overflow interrupts) also for a real time clock. I cannot use another timer for this clock.
The real time clock works perfectly when USB is disconnected. If USB data is being transmitted, however, it runs slightly slower (by 0.5% or so). It seems that intermittent overflow interrupts get lost. My ATMega168 runs at 20 MHz, so at a timer frequency of 50 kHz an overflow occurs every 400 cycles. For the interrupt to be occasionally missed it would take to disable them for more than 400 cycles... is that a likely cause?
The real time clock works perfectly when USB is disconnected. If USB data is being transmitted, however, it runs slightly slower (by 0.5% or so). It seems that intermittent overflow interrupts get lost. My ATMega168 runs at 20 MHz, so at a timer frequency of 50 kHz an overflow occurs every 400 cycles. For the interrupt to be occasionally missed it would take to disable them for more than 400 cycles... is that a likely cause?