The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
The purpose of this lab is to control and program the serial port of the micro-controller in a given sequence. Two switches SW1 and SW2 are connected to the micro-controller input port bits P1.1 and P1.2. The two switches define the required Baud rate requirements for the serial communication as follows:
CS 343
LAB7 – Using the 8051 Serial Port and Interrupts
Overview
The purpose of this lab is to control and program the serial port of the
micro-controller in a given sequence. Two switches SW1 and SW2 are
connected to the micro-controller input port bits P1.1 and P1.2. The two
switches define the required Baud rate requirements for the serial
communication as follows:
SW1
0
0
1
1 SW2
0
1
0
1 Baud (bps)
1200
2400
4800
9600 Steps
1. First, write a subroutine ”BCODE” (Baud Code) starting at code
address 200H to detect the setting of SW1 and SW2 and return a
value in accumulator B (0 for 1200, 1 for 2400, 2 for 4800, and 3 for
9600 Baud). It also setup the TH1 register for the requested BAUD
rate.
2. Second, write a subroutine “CONFIG” (Timers, Interrupts, and Serial
Configuration) starting at code address 300H to configure the serial
port for Mode 1, timer 0 for mode 1, and timer 1 for mode 2. Also it
enables the timer 0 interrupt and start timer 0 and timer 1.
.
3. Third, write a subroutine “SDISPLAY”” (Serial Display) starting at
code starting address of 400H to display on the serial port the
message “SERIAL BAUD IS XXXX BPS”. “XXXX” is the actual Baud
rate value selected. The subroutine will use polling on the TI flag.
4. Fourth, write a Timer 0 Interrupt Service Routine “TIMER0H” at
address 500H to provide maximum delay in updating port 3 based on
the status of input port 2.. 5. Test and debug your program. Also document and submit your final
report along with the well documented list file. Monitor the serial port
window and verify the SBUF contents using the ASCII code for the
selected message and associated BAUD rate. You can slow the
SBUF update by controlling the MC clock using the clock window in
the PREPHERALS selection. Make sure to check the “4x” box.
6. Modify the program in order to perform serial character transmission
using the serial port interrupt instead of the use of polling on the TI
flag. The processor will be reading Port 2 (P2) and outputting the
input byte to Port 3 (P3) while the serial message is being
transmitted.
7. Document the new program and explain how the interrupt structure
worked for Timer 0 and the Serial Port.
-----------