atmega323l ATMEL Corporation, atmega323l Datasheet - Page 47

no-image

atmega323l

Manufacturer Part Number
atmega323l
Description
Atmega323 8-bit Avr Microcontroller With 32k Bytes Of In-system Programmable Flash
Manufacturer
ATMEL Corporation
Datasheet
Timer/Counter0 Control
Register – TCCR0
Timer/Counter2 Control
Register – TCCR2
1457G–AVR–09/03
Timer/Counter0 and 2 can also be used as 8-bit Pulse Width Modulators. In this mode,
the Timer/Counter and the Output Compare Register serve as a glitch-free, stand-alone
PWM with centered pulses. Refer to page 49 for a detailed description on this function.
• Bit 7 – FOC0/FOC2: Force Output Compare
Writing a logical one to this bit, forces a change in the Compare Match output pin PB3
(Timer/Counter0) and PD7 (Timer/Counter2) according to the values already set in
COMn1 and COMn0. If the COMn1 and COMn0 bits are written in the same cycle as
FOC0/FOC2, the new settings will not take effect until next Compare Match or Forced
Output Compare Match occurs. The Force Output Compare bit can be used to change
the output pin without waiting for a Compare Match in the timer. The automatic action
programmed in COMn1 and COMn0 happens as if a Compare Match had occurred, but
no interrupt is generated and the Timer/Counters will not be cleared even if CTC0/CTC2
is set. The corresponding I/O pin must be set as an output pin for the FOC0/FOC2 bit to
have effect on the pin. The FOC0/FOC2 bits will always be read as zero. Setting the
FOC0/FOC2 bits has no effect in PWM mode.
• Bit 6 – PWM0/PWM2: Pulse Width Modulator Enable
When set (one) this bit enables PWM mode for Timer/Counter0 or Timer/Counter2. This
mode is described on page 49.
• Bits 5, 4 – COM01, COM00/COM21, COM20: Compare Output Mode, Bits 1 and 0
The COMn1 and COMn0 control bits determine any output pin action following a com-
pare match in Timer/Counter0 or Timer/Counter2. Output pin actions affect pins
PB3(OC0) or PD7(OC2). This is an alternative function to an I/O port, and the corre-
sponding direction control bit must be set (one) to control an output pin. The control
configuration is shown in Table 12.
Table 12. Compare Mode Select
Notes:
Bit
$33 ($53)
Read/Write
Initial Value
Bit
$25 ($45)
Read/Write
Initial Value
COMn1
0
0
1
1
1. In PWM mode, these bits have a different function. Refer to Table 15 for a
2. n = 0 or 2
(2)
description.
FOC0
FOC2
R/W
R/W
7
0
7
0
COMn0
0
1
0
1
PWM0
PWM2
R/W
R/W
6
0
6
0
COM01
COM21
Description
Timer/Counter Disconnected from Output Pin OCn
Toggle the OCn Output Line.
Clear the OCn Output Line (to Zero).
Set the OCn Output Line (to One).
R/W
R/W
5
0
5
0
(1)
COM00
COM20
R/W
R/W
4
0
4
0
CTC0
CTC2
R/W
R/W
3
0
3
0
CS02
CS22
R/W
R/W
2
0
2
0
ATmega323(L)
CS01
CS21
R/W
R/W
1
0
1
0
CS00
CS20
R/W
R/W
0
0
0
0
TCCR0
TCCR2
47

Related parts for atmega323l