In this lab, you will continue work with the 8051 and interface
with a Liquid Crystal Display (LCD) unit. The output you will
display on the LCD depends on which of three modes your main
program is in:
- A Start_LCD mode in which the LCD displays a
"Ready..." string.
- A Load mode in which the LCD displays a
user-inputted number.
- A Count Up/Down mode in which the LCD will
display the numbers 0 to 15 in an ascending or
descending sequence.
You will take existing LCD interface code and use its functions
to write a main program implementing the above functionality.
You will wire a breadboard with the necessary components to
physically demonstrate a working system after downloading
your compiled program to an 8051.
- Check out lab materials from a TA (one per group).
The three modes will be selected using an external DIP switch.
Depending on the DIP switch your materials pack has, you may not
use all the pins on the switch.
Use the following schematic. You should refer to the
8051 Pinout Diagram in assembling your
circuit.
In case you need to know, breadboards are configured such that
certain sockets are connected together, like so:
Note that you have not been provided with a chip socket, so you must
leave adequate room for the 8051. The 8051 has 20 pins on either side.
Warning: Previous quarters have not treated
the DIP switches kindly. Please use a blunt edge such as the head of
a flathead screwdriver to ease the switch out of the socket from
both sides - do not pry the DIP switch off by hand. Be similarly cautious
with the LCD unit.
You will now write code to interface with the LCD.
- Download and extract the 8051 compiler to your home directory.
- You will likely want to save your work in ~/c51 (the same directory the compiler was extracted to).
- Download io.c, io.h, and main.c to your new folder.
- Modify main.c, implementing the proper functionality as described in the Introduction.
Note: You must not add new
sbit variables.
Hint: If you wanted to extract the four most significant bits of the number 0x5B, the C syntax would be:
(0x5B >> 4) & 0xF
- Modify the Start_LCD mode so that "Ready..." (or your own short message) scrolls across the LCD screen.
Hint: The LCD screen is divided into two halves.
GoToXY(r,c)
may prove useful.