AT89S4051 Atmel Corporation, AT89S4051 Datasheet - Page 14

no-image

AT89S4051

Manufacturer Part Number
AT89S4051
Description
Manufacturer
Atmel Corporation
Datasheets

Specifications of AT89S4051

Flash (kbytes)
4 Kbytes
Max. Operating Frequency
24 MHz
Cpu
8051-12C
Max I/o Pins
15
Uart
1
Sram (kbytes)
0.25
Operating Voltage (vcc)
2.7 to 5.5
Timers
2
Isp
SPI

Available stocks

Company
Part Number
Manufacturer
Quantity
Price
Part Number:
AT89S4051-24SU
Manufacturer:
MICROCHIP/微芯
Quantity:
20 000
15. Timer/Counters
16. Pulse Width Modulation
14
AT89S2051/S4051
The AT89S2051/S4051 have two 16-bit Timer/Counters: Timer 0 and Timer 1. The Timer/Coun-
ters are identical to those in the AT89C2051/C4051. For more detailed information on the
Timer/Counter operation, please click on the document link below:
Timer 0 and Timer 1 may be configured as an 8-bit pulse width modulator by setting the PWMEN
bit in PCON. The generated waveform is output on the Timer 1 input pin, T1. In PWM mode
Timer 0 acts as an 8-bit prescaler to select the PWM timebase. Timer 0 is forced into Mode 2 (8-
bit auto-reload) by PWMEN and the value in TH0 will determine the clock division from 0 (FFh)
to 256 (00h). Timer 1 acts as the 8-bit PWM counter. TL1 counts once on every overflow from
TL0. TH1 stores the 8-bit pulse width value. On the FFh-->00h overflow of TL1, the PWM output
is set high. When the count in TL1 matches the value in TH1, the PWM output is set low. There-
fore, the output pulse width is proportional to the value in TH1. To prevent glitches, writes to TH1
only take effect on the FFh-->00h overflow of TL1. However, a read from TH1 will read the new
value at any time after a write to TH1. See
Figure 16-1. Pulse Width Modulation (PWM) Output Waveform
Figure 16-2. Timer 0/1 Pulse Width Modulation Mode
TL0 counts once every machine cycle (1 machine cycle = 12 clocks in X1 mode) and TH0 is the
reload value for when TL0 overflows. Every time TL0 overflows TL1 increments by one, with TL0
overflowing after counting 256 minus TH0 machine cycles.
To calculate the pulse width for the PWM output on pin T1, users should use the following
formula:
http://www.atmel.com/dyn/resources/prod_documents/DOC4316.PDF
TH1 * (256 - TH0) * (1/clock_freq) * 12 = Pulse Width
OSC
÷ ÷ 12
TH0
TL0
Figure 16-1
OCR
TH1
TL1
=?
for PWM waveform example.
PWM
Counter Value (TL1)
Compare Value (TH1)
PWM Output (T1)
P3.5
3390E–MICRO–6/08

Related parts for AT89S4051