ee219 lab8 serial

4
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

Upload: saad-iftikhar

Post on 21-Apr-2015

106 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: EE219 Lab8 Serial

NATIONAL UNIVERSITY OF SCIENCES AND TECHNOLOGY

College of Electrical and Mechanical EngineeringDepartment of Electrical Engineering

EE-219 Microprocessor & Digital SystemsSpring 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.

Page 2: EE219 Lab8 Serial

Org OOHMAIN:MOV TMOD,#20H ;timer 1,mode 2(auto reload)MOV TH1,#-6 ;4800 baud rateMOV SCON,#50H ;8-bit, 1 stop, REN enabledSETB TR1 ;start timer 1HERE: JNB RI,HERE ;wait for char to come inMOV A,SBUF ;saving incoming byte in AINC A CLR RI ;get ready to receive next ;byte

AGAIN: MOV SBUF,A ; A to transferHERE: JNB TI,HERE ;wait for the last bitCLR TI ;clear TI for next charSJMP HERESJMP $END

Page 3: EE219 Lab8 Serial

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 voltagelevels 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 toset 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.