1 EE 3954 Microprocessors and Microcontrollers Lab #5

advertisement
EE 3954
Microprocessors and Microcontrollers
Lab #5
Asynchronous Serial Communications
Figure 1. The laboratory board’s asynchronous serial port.
PURPOSE:
This lab involves the use of the microcontroller’s built-in Universal
Synchronous/Asynchronous Receiver Transmitter (USART). The USART will be used to
communicate with the laboratory’s Personal Computer (PC) via a terminal program
(HyperTerminal).
PREPARATION:
A) Read and understand Section 18 (especially 18.4) of the Reference Manual,
B) Read and understand Section 10 (especially 10.2) of the Datasheet,
C) YOU MUST HAVE A FLOWCHART OF YOUR PROGRAM READY
BEFORE YOU CAN START THE LAB. WE WILL NOT HELP YOU
UNLESS YOU HAVE A FLOWCHART!
DETAILS:
A)
The PIC microcontroller must be setup for serial communications with the PC
as follows:
19,200 baud, 8 data bits, Transmitter enabled, Transmitter
interrupt disabled, Receiver enabled, Receiver interrupt disabled.
B)
Write a program that:
• Transmits (via the USART) the Main Menu that was provided to you,
• Transmits (via the USART) your First Name if the character uppercase ‘F’
is received from the PC,
• Transmits (via the USART) your Last Name if the character uppercase ‘L’
is received from the PC,
1
•
•
•
•
NOTE:
C)
Transmits (via the USART) your Student PID# if the character uppercase
‘P’ is received from the PC,
Toggles the PIC Board’s RC2 LED if the character ‘2’ is received from
the PC (recall that LED is lit if RC2 = logic 1),
Toggles the PIC Board’s RC1 LED if the character ‘1’ is received from
the PC (recall that LED is lit if RC1 = logic 1),
Transmits (via the USART) the Main Menu if the character uppercase ‘M’
is received from the PC.
An ASCII character can be moved to register W using the A prefix. For
example, movlw A’M’ moves the ascii character ‘M’ to W.
Test your program using the PuTTY program on the PC to communicate with
your PIC board.
BACKGROUND:
The PIC Micro can communicate to the desktop computer the via serial communication
ports by using the PuTTY program on the PC. This program can be started by selecting
the PuTTY icon on the Windows desktop. After opening PuTTY, select the PIC_Term
settings and select Load. This should set your communications to: COM4, 19,200 baud, 8
data bits, 1 stop bit. Then select “Open”:
2
You should see a PuTTY terminal window as shown:
Now you are ready to communicate with the PIC microcontroller.
RESULTS REQUIRED:
•
•
Demonstrate the program’s operation on the development kits to instructor.
Report containing:
o Flow Chart of your program.
o Copy of the Assembly language program that you wrote.
o Brief description of how your program works as well as a brief description
of the results observed that confirms that your program worked as
designed.
3
Download