






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A lab exercise from the electrical and computer engineering (ece) 341 course at the university of idaho. The lab focuses on inter-processor communications and io handshaking, specifically in the context of a master-slave configuration with a two-line lcd. Students will write functions to initialize the lcd, display text, and manage cursor positioning. They will also investigate concepts of efficient code design and best practices. Figure suggestions for modeling the software and assignment tasks.
Typology: Lab Reports
1 / 10
This page cannot be seen from the preview
Don't miss anything!







March 2, 2009
The purpose of this laboratory exercise is to investigate concepts involving inter processor communications and IO handshaking. You will experiment with mechanisms required to synchronize asynchronous systems using both hardware and hardware handshaking as well as explicit and implicit handshaking.
The concepts of this lab are presented in Chapter 6 of the course notes. You will manage bi-directional parallel data exchange in a master-slave configuration. You will write functions the displays single characters, text strings, and position the cursor to place the display characters at specific positions on a two line LCD. You will design a program that makes efficient use of processor time and uses best practices for code design. The full LCD data sheet is available on the ECE 341 Web site at http://www.ece.uidaho.edu/ee/classes/ECE341/datasheets/LCD_Manual.pdf. Figure 5 through Figure 8 of Appendix D are suggestion for modeling the software to complete the assigned task.
i. Appropriately sets the LCD RS and RW controls ii. Positions the LCD cursor to the specified position in the range of 0 to 31. iii. LCD cursor positions in the range of 0 to 15 positions the cursor to the appropriate location on the first line of the LCD. iv. LCD cursor positions in the range of 16 to 31 positions the cursor to the appropriate location on the second line of the LCD v. Verify that the busy flag is reset before exiting the program
Figure 1. LCD write cycle time diagram Figure 2. LCD read cycle time diagram Figure 3. LCD character position table
No Magic Numbers The course text warns against the use of magic numbers. This is most easily accomplished by using define statements in C. To initiate your quest to stamp out magic numbers, here is a list of define statements for lab 6. // LCD setup commands #define LCD_CFG 0x38 // Configuration mode for 8 bit data bus #define LCD_ENTRY 0x06 // Block flashing cursor – // increment pointer #define LCD_ON 0x0F // Activate LCD #define LCD_HOME 0x02 // Put cursor in left most position #define LCD_CLR 0x01 // Clear characters off LCD // LCD Status status definitions #define LCD_ADDR 0x7f // Address mask for status register #define LCD_BF 0x80 // Busy flag mask for status register #define LCD_BF_bit 7 // Busy flag bit for status register // LCD Address control constants #define LCD_DDRAM 0x80 // DD Ram Set control #define LCD_LINE1 0x10 // End of LCD line # #define LCD_LINE2 0x40 // Start of LCD line # // R3000 outputs for LCD control bit definitions #define LCD_EN 0x04 // LCD enable mask (Port D) #define LCD_EN_bit 2 // LCD enable bit (Port D) #define LCD_RS 0x10 // LCD RS mask (Port D) #define LCD_RS_bit 4 // LCD RS bit (Port D) #define LCD_RW 0x20 // LCD R/!W mask (Port D) #define LCD_RW_bit 5 // LCD R/!W bit (Port D) Test Code “main” Function Two “main” functions are provided to allow you to evaluate your code. Use the following main function to demonstrate that your program meets the functional requirements of described in the Assignment Tasks section above. void main(void) { int x; LCD_init(); x = 0; LCD_goto_pos(16); LCD_puts("ECE 341 Lab 6"); while(1) { LCD_goto_pos(0); LCD_puts("Hello World -- "); LCD_putc(x+'0'); x++;
Direct Serial Link to PC Capture Procedures http://www.ece.uidaho.edu/ee/classes/ECE341/refs/Capture_WaveForm_Agilent_54622D.pdf Floppy Disk Capture Procedures The following is a process to capture the LCD R/!W and the E signals.
With a little spreadsheet messaging, a plot similar Figure 4 can be made.
-0. 0
1
2
3
4 0 500 1000 1500 2000 Time - uS Volts (^) CH 1 LCD E CH 2 LCD - RS Figure 4. Timing waveform for LCD E and RS
LCD_putc LCD Check status Control Character? No Execute Control Sequence Cursor Addr == EOL 1? Yes Yes (^) Shift cursor address No Set RW= 0 , RS = 1 Print character Done Busy? Yes No LCD Check status Busy? Yes No Figure 8. LCD put character flow diagram