ECE 341 Lab 6: Handshaking and Processor Synchronization with LCD, Lab Reports of Electrical and Electronics Engineering

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

Pre 2010

Uploaded on 08/19/2009

koofers-user-jyd-1
koofers-user-jyd-1 🇺🇸

10 documents

1 / 10

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ECE 341 Lab 6
Handshaking – Processor Synchronization
March 2, 2009
Purpose
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.
Concepts
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.
Assignment tasks
1. The “main” function will:
i. Initialize the LCD.
ii. Display the text “ECE 341 Lab 6” on the second line of the LCD. This text
is to be written only once and must remain on the LCD for the remaining of
the program.
iii. “Display the text “Hello World -- #” on the first line of the LCD. The value
“#” will increment from 0 through 9 that updates every 250 ms.
2. The “LCD_init” function:
i. Sets the LCD registers according to the Chapter 6 of the ECE 340 course
notes.. (See http://ee.uidaho.edu/ee/classes/ECE340/notes/notes.htm )
ii. Produce a blinking cursor in the left most position of the first (top) line of
the display.
3. The “LCD_get_status” function:
i. Sets the R3000 Port A for read (input) mode.
ii. Appropriately sets the LCD RW and RS controls
iii. Returns a single byte (char data type) containing the LCD Busy Flag in the
most significant bit location (bit seven) and the DDRAM address in bits
zero through six.
iv. Resets the R3000 Port A for write (output) mode.
4. The “LCD_goto_pos” function (See Figure 3 of Appendix A):
1
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download ECE 341 Lab 6: Handshaking and Processor Synchronization with LCD and more Lab Reports Electrical and Electronics Engineering in PDF only on Docsity!

ECE 341 Lab 6

Handshaking – Processor Synchronization

March 2, 2009

Purpose

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.

Concepts

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.

Assignment tasks

  1. The “main” function will: i. Initialize the LCD. ii. Display the text “ECE 341 Lab 6” on the second line of the LCD. This text is to be written only once and must remain on the LCD for the remaining of the program. iii. “Display the text “Hello World -- #” on the first line of the LCD. The value “#” will increment from 0 through 9 that updates every 250 ms.
  2. The “LCD_init” function: i. Sets the LCD registers according to the Chapter 6 of the ECE 340 course notes.. (See http://ee.uidaho.edu/ee/classes/ECE340/notes/notes.htm ) ii. Produce a blinking cursor in the left most position of the first (top) line of the display.
  3. The “LCD_get_status” function: i. Sets the R3000 Port A for read (input) mode. ii. Appropriately sets the LCD RW and RS controls iii. Returns a single byte (char data type) containing the LCD Busy Flag in the most significant bit location (bit seven) and the DDRAM address in bits zero through six. iv. Resets the R3000 Port A for write (output) mode.
  4. The “LCD_goto_pos” function (See Figure 3 of Appendix A):

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

  1. The “LCD_putc” function: i. Checks the LCD busy flag and determined the LCD cursor position each time upon entry to the function. ii. Automatically repositions the cursor to the second line of the LCD for ASCII string longer than 16 characters. iii. Translates the ‘\n’ character to a “clear LCD operation”. iv. Translates the ‘\r’ character
  2. to LCD_goto_pos(0); if the cursor is on the first line.
  3. to LCD_goto_pos(16); if the cursor is on the second line. v. Appropriately sets the LCD RS and RW controls vi. Writes the ASCII character on the LCD
  4. The “LCD_puts” function: i. Has a NULL terminated ASCII string passed to it. ii. Display the string by passing the individual characters to the LCD_putc function.
  5. The “ms_sw_delay function”: i. Implement a software delay function using a polling process developed for one of the earlier assignments. ii. Do not use any interrupts.
  6. Perform the measurements to complete the “Actual” column in Table II. (See Appendix B for a test program and Appendix C for instructions to help in making these measurements.)

Appendix A

Figure 1. LCD write cycle time diagram Figure 2. LCD read cycle time diagram Figure 3. LCD character position table

Appendix B

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++;

Appendix C

Capturing Oscilloscope Waveforms

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.

  1. Connect the oscilloscope channel 1 probe to the LCD “E” signal (PD.2).
  2. Connect the oscilloscope channel 2 probe to the LCD “R/!W” signal (PD.5).
  3. Run the test program the repeatedly writes the character “A” to the LCD.
  4. Hit the “Auto” button on the oscilloscope to do a rough setting.
  5. Set the trigger to sync for a negative edge trigger on channel 2. The following procedure can be used to capture a trace using the Agilent 54622D oscilloscopes.
  6. Note the two buttons just below the vertical sensitivity knobs on the oscilloscope. They are marked “Save/Recall” and “Quick Print”. Press the “Save/Recall” button. A series of messages will be displayed on the oscilloscope screen. The buttons below the messages are called “soft buttons”.
  7. On the soft buttons press “Formats” i. Select “CSV” (comma separated variables) ii. Check that the format is set for “CSV” iii. Select the “Print to disk” soft key iv. Make sure the “Disk” line is checked v. Press the up-arrow soft key vi. Press “Floppy” and made make sure is checked
  8. Put a 3.5” floppy disk is put into the disk drive below the screen.
  9. Press the “Quick Print” button. A message will displayed on the screen that tells you the file name and the progress.
  10. After the save process is finished, pull the disk out of the oscilloscope and put into the A drive on the PC. Copy the file to your lab directory and open with EXCEL The resulting Excel file should similar too Table III. Table III. Waveform capture data x-axis 1 2 second Volt Volt -9.40E-06 3.50E-02 3.18E+ -9.35E-06 3.50E-02 3.18E+ -9.30E-06 3.50E-02 3.25E+ -9.25E-06 3.50E-02 3.18E+ -9.20E-06 3.50E-02 3.18E+ -9.15E-06 3.50E-02 3.18E+ -9.10E-06 1.60E-01 3.18E+

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