Sunteți pe pagina 1din 3

NATIONAL UNIVERSITY OF SCIENCES AND TECHNOLOGY College of Electrical and Mechanical Engineering Department of Electrical Engineering EE-219 Microprocessor

& Digital Systems Spring 2012 (DE 32-EE) 8051 Microcontroller Hardware Lab # 2 UART BASED SERIAL COMMUNICATION BETWEEN 8051 AND IBM PC
OBJECTIVES: To interface MAX232 level shifter IC to 8051 To perform data transfer between PC and 8051 using serial UART interface using serial port programming REFERENCE: Mazidi and McKinlay, The 8051 Microcontroller and Embedded Systems, Chapter 10 www.maxim-ic.com MAX232 datasheet: http://datasheets.maxim-ic.com/en/ds/MAX220-MAX249.pdf MATERIALS: 8051 assembler and simulator (keil) 8051 generic board MAX232 with required capacitors of 10 uF capacitance DB-9 RS232 connector with serial cable IBM PC/ compatible computer with COM1 or COM2 port Hyperterminal application ACTIVITY Test the functionality of MAX232 IC after connecting it in proper configuration as explained in the lab and mentioned in book. Connect 8051 serial port with the serial port of PC. Do proper UART settings on PC

Write code on 8051 which continuously receives data on its serial port and transmits it back to the PC after increment of 1 in the data.

Org OOH MAIN: MOV TMOD,#20H MOV TH1,#-6 MOV SCON,#50H SETB TR1 HERE: JNB RI,HERE MOV A,SBUF INC A CLR RI AGAIN: MOV SBUF,A HERE: JNB TI,HERE CLR TI SJMP HERE SJMP $ END

;timer 1,mode 2(auto reload) ;4800 baud rate ;8-bit, 1 stop, REN enabled ;start timer 1 ;wait for char to come in ;saving incoming byte in A ;get ready to receive next ;byte ; A to transfer ;wait for the last bit ;clear TI for next char

LAB WORKSHEET
Name: Date: Class:

1. The 8051 TxD and RxD signals are (are, are not) TTL-compatible. 2. In this lab, what is the role of the MAX233 (MAX232) chip?

A line driver such as the MAX232 chip is required to convert RS232 voltage levels to TTL levels, and vice versa
3. With XTAL=11.0592 MHz, what is the maximum baud rate for the 8051?
the maximum Baud rate produced can be 28,800 but its not compatible with most PCs so we use 9600.

4. Show how to achieve the maximum baud rate in Question 3.

The machine cycle frequency of 8051 = 11.0592 / 12 = 921.6 kHz, and 921.6 kHz / 32 = 28,800 Hz is frequency by UART to timer 1 to set baud rate.
5. What is the role of TI and RI?

(TI) Transmit interrupt flag. Set by HW at the begin of the stop bit mode 1. And cleared by SW (RI) Receive interrupt flag. Set by HW at the begin of the stop bit mode 1. And

cleared by SW
6. True or false. The 8051 can transfer data in full-duplex. True 7. For full duplex, what are the absolute minimum signals needed between the 8051 and the PC? Give their names.

S-ar putea să vă placă și