1 force output compare, 2 compare match blocking by tcntn write, 3 using the output compare unit – Rainbow Electronics ATtiny43U User Manual

Page 82: Attiny43u, Data bus

Advertising
background image

82

8048B–AVR–03/09

ATtiny43U

Figure 12-3. Output Compare Unit, Block Diagram

The OCRnx Registers are 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 dou-
ble buffering is disabled. The double buffering synchronizes the update of the OCRnx Compare
Registers to either top or bottom of the counting sequence. The synchronization prevents the
occurrence of odd-length, non-symmetrical PWM pulses, thereby making the output glitch-free.

The OCRnx Register access may seem complex, but this is not case. When the double buffering
is enabled, the CPU has access to the OCRnx Buffer Register, and if double buffering is dis-
abled the CPU will access the OCRnx directly.

12.5.1

Force Output Compare

In non-PWM waveform generation modes, the match output of the comparator can be forced by
writing a one to the Force Output Compare (nx) bit. Forcing Compare Match will not set the
OCFnx Flag or reload/clear the timer, but the OCnx pin will be updated as if a real Compare
Match had occurred (the COMnx1:0 bits settings define whether the OCnx pin is set, cleared or
toggled).

12.5.2

Compare Match Blocking by TCNTn Write

All CPU write operations to the TCNTn Register will block any Compare Match that occur in the
next timer clock cycle, even when the timer is stopped. This feature allows OCRnx to be initial-
ized to the same value as TCNTn without triggering an interrupt when the Timer/Counter clock is
enabled.

12.5.3

Using the Output Compare Unit

Since writing TCNTn in any mode of operation will block all Compare Matches for one timer
clock cycle, there are risks involved when changing TCNTn when using the Output Compare
Unit, independently of whether the Timer/Counter is running or not. If the value written to TCNTn
equals the OCRnx value, the Compare Match will be missed, resulting in incorrect waveform

OCFnx (Int.Req.)

=

(8-bit Comparator )

OCRnx

OCnx

DATA BUS

TCNTn

WGMn1:0

Waveform Generator

top

FOCn

COMnx1:0

bottom

Advertising