实现HD44780开发版的LCD控制。
Requirement
This assignment has three parts:
- Programming Pre-submission: A subset of the complete program needs to be submitted via the Assignments link on the Connex site on or before March 13, 2020 well before 1:00 am.
- Programming Submission: The final program will be submitted via the Assignments link on the Connex site on or before March 22, 2020 well before 1:00 am. The main submission file should be in a file called display.asm; the extended work should be in a file called display_ext.asm.
- Demonstration: You will be required to demonstrate the functioning of the programming part of your assignment to a member of the teaching team.
Objectives
- Gain confidence with assembly language programming. Create effective subroutines/functions with parameters. Use peripherals: the LCD
- Become familiar with the use of busy-waiting
- Become familiar with the use of interrupts
Assignment 3 Description
Please note for all programing assignments, you must include your name and student number and edit the documentation appropriately. Make sure the submitted work is yours and not someone else.
The LCD
The boards we are using have a Hitachi HD44780 compatible LCD display that has its own (simple) processor. To communicate with that processor a specific protocol is used that initializes and controls the LCD screen. Learn more about how the LCD controller works by looking at the data sheet: https://www.sparkfun.com/datasheets/LCD/HD44780.pdf
A previous CSC 230 student has written a library of subroutines for this assignment. The table below lists the subroutines, their parameters and what they do.
There is an example program, that shows how to use the LCD functions in the file: lcd_example.asm. Review both files carefully until you are able to understand their functionality. While doing that, search for a way to set the number of rows on the LCD to 2 and the number of columns to 20.
LCD Moving Message Sign
LCD advertising signs often move written messages on a screen and flash. The movement and the flashing are very effective at attracting attention. The goal of this programming task will be to display messages, using the buttons to move between them and them down and across the screen, and to display and flash both messages. Please name this file as “display.asm” for submission on connex.
In particular, the program will need to:
- a. Create two messages that will be displayed on the screen. For example, assume: msg1 = “LillAnne Jackson” msg2 = “Teaches Assembly” (Be sure to use two messages personalized for yourself!)
- b. Using the messages (msg1 and msg2) create another two messages that contain the same characters, but in reverse order. Using the above example messages, the messages, called msg3 and msg4, would be: msg3 = “noskcaJ ennAlliL” msg4 = “ylbmessA sehcaeT”
- c. The sign will scroll (cycle) through msg1, msg2, msg3, and msg4, displaying them on the LCD screen, using the specifications below:
- i. When the program starts, both rows of the the LCD screen will be completely filled with asterisk or star “*” characters.
- ii. When the ‘UP’ button is pressed, the characters on the 2nd line of the screen to move up to the 1st line and the next message will appear on the 2nd line. (After the start up screen msg1 appears, followed by msg2 then msg3 then msg4.) For example, starting from the initial start up screen, 5 presses of the UP button would “scroll up” yielding: press UP: press UP: press UP: press UP: press UP:
- iii. When the “DOWN’ button is pressed, the characters on the 1st line of the screen move down to the 2nd line and the next message will appear on the 1st line. (After the start up screen msg4 appears, followed by msg3 then msg2 then msg1.) For example, starting from the initial start up screen, 5 presses of the UP button would “scroll down” yielding:
- iv. When the ‘SELECT’ button is pressed, the current screen will alternately display the current messages and the start up screen (completely filled with ‘*’ characters) alternating every 0.5 second. Essentially, it will flash.
- v. When the ‘LEFT’ button is pressed, the screen will display the number of button pressed on the first line and the words “Buttons Pressed” on the second line.
- vi. When the ‘RIGHT’ button is pressed, the screen will scroll through the messages in (up) order, msg1 followed by msg2 followed by msg3 followed msg4 followed by msg1 etc, changing every second.
Implementation Help
The instructor’s solution has the following in the data:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19; sample strings
; These are in program memory
msg1_p: .db "LillAnne Jackson", 0
msg2_p: .db "Teaches Assembly", 0
.dseg
;
; The program copies the strings from program memory
; into data memory.
;
msg1: .byte 40
msg2: .byte 40
; These strings contain the (up to) 18 characters to be displayed on the LCD
; Each time through, the 18 characters are copied into these memory locations
line1: .byte 19
line2: .byte 19
line3: .byte 19
line4: .byte 19
With these data definitions, the main loop of the application looks like:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44initialize the lcd
output the startup screen ("*"characters) on lcd
copy the strings from program to data memory
create the two reversed strings, store in data memory
startString = "******************"
line1 = startString
line2 = startString
msg_counter=0
button_count = 0
when a button is pressed:
increment button_count
if button is UP:
msg_counter += 1 remainder 4
line1 = line2
line2 = msg(msg_counter)
display(line1, line2)
if button is DOWN:
msg_counter -= 1 remainder 4
line2 = line1
line1 = msg(msg_counter)
display(line1, line2)
if button is SELECT:
display (line1, line2)
delay (0.5 second)
display (startString, startString)
delay (0.5 second)
if button is LEFT:
line_count = "** " + button_count + " **"
text_line = "Buttons Pressed"
display(line_count, text_line)
if button is RIGHT:
msg_counter = 1
do until another button is pressed:
line1 = msg(msg_counter)
msg_counter += 1 remainder 4
line2 = msg(msg_counter)
display(line1, line2)
delay (1.0 second)
function display(lineA, lineB)
set row counter to 1 and column counter to 1
display lineA
set row counter to 2 and column counter to 1
display lineB
You should make extensive use of subroutines in your code, including the delay code . The solution is ~300 lines of assembly language. Start now!
Extending the Moving Message Sign
Now, add some features. Here are some options. You can choose any one of them or suggest an alternative.
- Implement a scrolling display for longer messages: Scroll them across the screen, wrapping such that a character that falls off one end will appear on the other.
- Allow button presses to increase and decrease the sign change speed
Please name this file as “display_extended.asm” for submission on connex.
In order to handle button presses gracefully you will have to do something other than busy loop waiting, either by checking the buttons in your delay subroutine or by using timer interrupts. Note that an extension that uses interrupts will achieve slightly better grades that one that does not.