CE-2800 Embedded Systems Software
Lab 6: LCD Messages
Objectives
- Become familiar with assembly language program design and instructions
- Use assembly language branch instructions to implement conditional logic
- Use assembly language instructions to implement subroutines and
subroutine calls
- Use device driver subroutines to initialize and read the keypad
- Develop device drivers to control the LCD display and USART
Assignment
In this lab, you are to write a program that makes use of (i.e. calls
subroutines from) the display_dd.asm and delay.asm files
to implement the functionality described below. Your "main" program should be
placed in a file named Lab6.asm.
Completing rs232_dd.asm
First, complete the rs232_sendMessage subroutine in the rs232_dd.asm
file you began in the previous lab assignment. This subroutine
transmits a character string of arbitrary length - to do so, this subroutine
must make repeated calls to the rs232_sendByte subroutine to transmit
each individual character in the string. The "arguments" to the
rs232_sendMessage subroutine are specified in the table below:
message (R30:R31, or Z register) |
This is the 16-bit address of the
character string in Program Memory that is to be transmitted. Note that
the string does not have to be null-terminated! |
length (R23) |
The length (in bytes, or characters)
of the string to be transmitted. |
There is no return value from rs232_sendMessage.
LCD display driver: display_dd.asm
The file display_dd.asm, which you must write from scratch, will contain
several subroutines that initialize and control the functionality of the LCD
display. The subroutines you are to implement must conform to the following
"interface" specification:
-
display_init –
Initializes the LCD display by invoking the rs232_init subroutine
(which you have already implemented in rs232_dd.asm) with the
correct "arguments" appropriate for the LCD (i.e. baud rate, parity,
etc). It also turns the backlight off, and sets the cursor on with
character blink (by calling rs232_sendByte with appropriate
arguments as described in the LCD technical documentation). The
display_init subroutine takes no arguments and returns nothing.
Note: be sure this subroutine incorporates a 20ms delay before sending
data to the LCD, in order to give the LCD sufficient time to boot during
power up.
-
display_clear –
clears the LCD display by calling rs232_sendByte with appropriate
arguments. Takes no arguments and returns no value. Note: be sure this
subroutine incorporates a delay of at least 5ms before returning in
order to give the LCD time to clear.
-
displayMessage –
Displays a string to the LCD display by calling
rs232_sendMessage
with appropriate arguments. The arguments to
displayMessage are
specified in the table below:
message (R30:R31, or Z
register) |
This is the 16-bit address
of the character string in Program Memory that is to be
displayed. Note that the string does not have to be
null-terminated! |
length (R23) |
The length (in bytes, or
characters) of the string to be displayed. |
There is no return value from displayMessage.
-
display_gotoLocation –
positions the cursor to a specific location within the LCD display. The
argument to this subroutine is passed via R23, which contains one
of the 32 opcodes described in the LCD technical documentation that
specify the cursor position. This subroutine returns no value.
Keypad driver: keypad_dd.asm
Download this keypad2_dd.asm file, whose
subroutines you will use within your Lab5.asm program. You needn't make any
modifications to this code, but in your Lab5.asm file you will have to define
three aliases as described at the top of keypad2_dd.asm. The use of the
subroutines are documented within the file itself, but you may find the
following table useful in terms of documentation of the values that are returned
in R25 and R24 as a result of calling the keypad_read subroutine.
Key |
R25 |
R24 |
none |
0 |
0 |
0 |
0 |
1 |
1 |
0 |
2 |
2 |
0 |
4 |
3 |
0 |
8 |
4 |
0 |
0x10 |
5 |
0 |
0x20 |
6 |
0 |
0x40 |
7 |
0 |
0x80 |
8 |
1 |
0 |
9 |
2 |
0 |
A |
4 |
0 |
B |
8 |
0 |
C |
0x10 |
0 |
D |
0x20 |
0 |
* |
0x40 |
0 |
# |
0x80 |
0 |
Delay library: delay.asm
Finally, you must use this delay.asm library
file (similar to code recently distributed in the USART demo sample) that
contains a subroutines delay,
delay60, and delay1000.
You must add a delay2 subroutine
that does what it's name implies.
Program Functionality
-
The LCD panel should be connected to the
USART.
-
The keypad should be connected to PORTA,
with the left side of the ribbon cable connected to the pin closest to
the power LED.
-
Your Lab5.asm program must first initialize the LCD and keypad.
Following that, it must repeatedly read the keypad. After each read, it
must determine which key was pressed to result in one of the following
actions:
- If keys A is pressed, the display should be cleared.
- If key B is pressed, the LCD display should be cleared and
"Hello, world!" should appear on line 1.
- If key C is pressed, the LCD display should be cleared and
"Hello, world!" should appear on line 2.
- If key D is pressed, the LCD display should be cleared and your
first name should appear on line 1, and your last name on line 2.
- if key * is pressed, the LCD should display all * characters on
line 1, leaving any text remaining on line 2. OPTION: Also turn the
backlight off when this key is pressed.
- if key # is pressed, the LCD should display all # characters on
line 2, leaving any text remaining on line 1. OPTION: Also turn the
backlight ON when this key is pressed.
- if an odd key from 1-9 is pressed, different messages (at least
8 characters each) should appear on line 1, leaving any text
remaining on line 2.
- if an even key from 0-8 is pressed, different messages (at
least 8 characters each) should appear on line 2, leaving any text
remaining on line 1.
-
Each of the messages should be stored in program memory as strings, but
where the first byte is a numerical value indicating the length (in
characters) of the string. Thus, the string "Hello, world!" would be
defined as follows:
message2: .DB 13, "Hello, world!" ; a
length-prefixed string, the 13 at the front indicates the number of
chars that follow
Demonstration
You must demonstrate your working program on your board before
the lab next week.
Lab Submission (due 11:00pm, Tuesday, January 24, 2012)
For your submission, you need only supply your working, fully commented
Lab5.asm, display_dd.asm and rs232_dd.asm files.
Upload your submission through
Blackboard (assignment "Lab 6").
Be sure to keep copies of all your files, in case something gets lost.
Grading
Your lab grade will be determined by the following
factors:
Program - comments and formatting are important
aspects of assembly language programming! And it has to work correctly.
Timeliness of
submission as stated in the
course policies.