Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
80c51 Intel Microcontroller has Two 16-bit timers/counters, Timer 0 and Timer
1. TMOD and TCON registers are used for setting and using these
timers/counters.
Both can be configured to operate either as timers or as event counters. In the
case of timers, register is incremented once every machine cycle. Hence timer is
considered as counter which counts machine cycles. One machine cycle has
about 12 oscillator periods. The count rate is about (1/12)Oscillator frequency.
In the case of Counter, register is incremented in response to a 1-0 transition to
its corresponding external input pin. In this function, the external input is sampled
during S5-P2 of the every machine cycle.
Microcontroller TMOD register(Not bit addressable)
M1 M0 Operating Mode
0 0 13 bit timer
0 1 16 bit timer/counter
GATE- When GATE=1 and TRx(in TCON) is set, Timer/Counter-x will run while
INT-x pin is
set high(Hardware Control). When GATE=0, Timer/Counter-x will run only
while TRx=1(software control).
C/(T)- Set 0 for timer operation and Set 1 for counter operation
M1- Mode Selector bit
M0- Mode Selector bit
Microcontroller TCON register(Bit addressable)
The serial port receive/transmit registers are both accessed at SBUF. The serial
port can operate in 4 modes as mentioned below.
Table-1
Based on SM0 and SM1 various baudrates are selected as shown in the table
below.
SM SM
0 1 Mode/Description/Baud rate
0 0 0,shift register,(Fosc./12)
As shown in the C program, it initializes timer 0 for delay and timer 1 for baud
rate of 9600 bps.
for(i=0;i<max;i++)
{
SBUF=transmit_array[i++]; /* Transmitting character array/*
while(!TI); TI=0;