12.07.2015 Views

ATmega32A Datasheet - Sunrom Technologies

ATmega32A Datasheet - Sunrom Technologies

ATmega32A Datasheet - Sunrom Technologies

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>ATmega32A</strong>Figure 14-3.Output Compare Unit, Block DiagramDATA BUSOCRnTCNTn= (8-bit Comparator )OCFn (Int.Req.)topbottomFOCnWaveform GeneratorOCnWGMn1:0COMn1:0The OCR0 Register is double buffered when using any of the Pulse Width Modulation (PWM)modes. For the normal and Clear Timer on Compare (CTC) modes of operation, the double bufferingis disabled. The double buffering synchronizes the update of the OCR0 Compare Registerto either top or bottom of the counting sequence. The synchronization prevents the occurrenceof odd-length, non-symmetrical PWM pulses, thereby making the output glitch-free.The OCR0 Register access may seem complex, but this is not case. When the double bufferingis enabled, the CPU has access to the OCR0 Buffer Register, and if double buffering is disabledthe CPU will access the OCR0 directly.14.5.1 Force Output CompareIn non-PWM waveform generation modes, the match output of the comparator can be forced bywriting a one to the Force Output Compare (FOC0) bit. Forcing compare match will not set theOCF0 Flag or reload/clear the timer, but the OC0 pin will be updated as if a real compare matchhad occurred (the COM0[1:0] bits settings define whether the OC0 pin is set, cleared ortoggled).14.5.2 Compare Match Blocking by TCNT0 WriteAll CPU write operations to the TCNT0 Register will block any compare match that occur in thenext timer clock cycle, even when the timer is stopped. This feature allows OCR0 to be initializedto the same value as TCNT0 without triggering an interrupt when the Timer/Counter clock isenabled.14.5.3 Using the Output Compare UnitSince writing TCNT0 in any mode of operation will block all compare matches for one timer clockcycle, there are risks involved when changing TCNT0 when using the output compare unit, independentlyof whether the Timer/Counter is running or not. If the value written to TCNT0 equals8155C–AVR–02/1176

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!