Documente Academic
Documente Profesional
Documente Cultură
By
Layout of Presentation
Introduction Timer Operation
Timer Mode Setting
13-bit timer, 16-bit timer, 8-bit auto reload, split timer Event counting or continuous timer using internal clock
Introduction
There are two timers in 8051 and three in 8052 Six SFRs control the timer operation of 8051 SFR Purpose
TCON TMOD TL0 TL1 TH0 TH1 Control Mode Timer0 low byte Timer1 low byte Timer0 high byte Timer1 high byte
Five additional SFRs are used for 8052 operation Let us first understand the function of 8051 timers
M0 0 1 0 1
Mode (Description) 0 13-bit timer 1 16-bit timer 2 8-bit auto reload 3 Split timer mode
Example: SETB
TR0
; start timer0
8052 Timer 2
8052 has one more timer (Timer2) in addition to the two just described. Five extra SFRs are added to accommodate Timer2; T2CON, TL2, TH2, RCAP2L, RCAP2H. The mode as well as the run control of Timer2 is set by T2CON register;
Bit T2CON.7 T2CON.6 T2CON.5 T2CON.4 T2CON.3 T2CON.2 T2CON.1 T2CON.0 Symbol TF2 EXF2 RCLK TCLK Description Timer2 overflow flag. Not set when TCLK or RCLK=1) Timer2 external flag. Set by external count signal Timer2 receiver clock. When set provides receiver clock Timer2 transmit clock. When set provides trasmit clock EXEN2 External enable. When set timer2 works on T2EX signal TR2 Timer2 run control bit; C/T2 Counter/timer select;1=event counter, 0=interval timer CP/RL2 Timer2 capture/reload flag. 1=capture, 0=auto reload.
SMOD bit in PCON register when set doubles the baud rate. Default values (i.e, PCON register SMOD bit=0) for Mode 1&3 is timer1 overflow rate32, whereas for Mode 2 it is crystal freq64.
Summary
This presentation describes the operation of timers in 8051 and 8052 microcontrollers and also describes the registers used for the operation of the serial port.