8051 Serial Port and Timer/Counter Serial Port Timer Counter - - PowerPoint PPT Presentation

8051 serial port and timer counter
SMART_READER_LITE
LIVE PREVIEW

8051 Serial Port and Timer/Counter Serial Port Timer Counter - - PowerPoint PPT Presentation

8051 Serial Port and Timer/Counter Serial Port Timer Counter Chatchai Jantaraprim (cj@coe.psu.ac.th) 8051 Serial Port Serial communications High speed CMOS signal levels Full duplex No modem status/control signals Registers SBUF Two


slide-1
SLIDE 1

8051 Serial Port and Timer/Counter

Serial Port Timer Counter

Chatchai Jantaraprim (cj@coe.psu.ac.th)

slide-2
SLIDE 2

8051 Serial Port

Serial communications High speed CMOS signal levels Full duplex No modem status/control signals Registers SBUF

Two separate data buffers for transmit and receive

SCON

Control register

SMOD

Addition bit to double baud speed

TH1

Timer/counter 1 high byte for baud rate control in mode 1, 3

slide-3
SLIDE 3

8051 Serial Port

SCON Register

RI TI RB8 TB8 REN SM2 SM1 SM0 7 6 5 4 3 2 1 SCON

slide-4
SLIDE 4

8051 Serial Port

SCON Register (cont.) RIReceive Interrupt Flag

Set by hardware on received. must clear by software

TITransmit Interrupt Flag

Set by hardware on transmitted, must clear by hardware

RB8 Receive bit 8

Mode 2,3 : copy of bit 8 Mode 1 & SM2 clear : copy of stop bit

TB8 Transmit bit 8

The 9th data bit of mode 2,3. Set or clear by software

REN Receive Enable

Set by software to enable reception, if is cleared reception will be blocked.

SM2 Serial Mode (bit 2)

Use in mode 2,3 for multiprocessor communications

slide-5
SLIDE 5

8051 Serial Port

SCON Register (cont.) SM1 & SM0Serial Mode (bit 6 & 7)

Operating modes

Operating modes Mode 08-bit shift register, f/12

1Mbit with 12Mhz Oscillator Frequency

Mode 18-bit UART, variable baud rate Mode 29-bit UART, f/64 or f/32

187.5K and 375K with 12MHz Oscillator Frequency

Mode 39-bit UART, variable baud rate

slide-6
SLIDE 6

8051 Serial Port

Baud Rate Variable Baud Rate SMOD Baud Rate = 2 x f

  • 384 x (256 - TH1)

Baud Rate f SMOD TH1 62.5K 12.000 1 FFh 19.2K 11.059 1 FDh 9.6K 11.059 0 FDh 4.8K 11.059 0 FAh 2.4K 11.059 0 F4h 1.2K 11.059 0 E8h

slide-7
SLIDE 7

8051 Serial Port

Initialize Serial Port Subroutine Set baud rate to 9600 for 11.0592 Crystal mov TMOD, #20h; set timer 1 for auto reload mov TCON, #41h; run counter 1 edge trig mov TH1, #0FDh; 9600 baud mov SCON, #50h; 8-bit data mode 1 Sending and Receiving Subroutines

sndchr: getchr: clr TI jnb RI, getchr mov SBUF, A mov A, SBUF txloop: jnb TI, txloop clr RI ret ret