8051 serial port and timer counter
play

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


  1. 8051 Serial Port and Timer/Counter Serial Port Timer Counter Chatchai Jantaraprim (cj@coe.psu.ac.th)

  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

  3. 8051 Serial Port SCON Register 7 6 5 4 3 2 1 0 SM0 SM1 SM2 REN TB8 RB8 TI RI SCON

  4. 8051 Serial Port SCON Register (cont.) RI�Receive Interrupt Flag Set by hardware on received. must clear by software TI�Transmit 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

  5. 8051 Serial Port SCON Register (cont.) SM1 & SM0�Serial Mode (bit 6 & 7) Operating modes Operating modes Mode 0�8-bit shift register, f/12 1Mbit with 12Mhz Oscillator Frequency Mode 1�8-bit UART, variable baud rate Mode 2�9-bit UART, f/64 or f/32 187.5K and 375K with 12MHz Oscillator Frequency Mode 3�9-bit UART, variable baud rate

  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

  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

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend