DOC PREVIEW
BOISE STATE ECE 332L - Lab 5

This preview shows page 1-2-3 out of 9 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Page 1 of 9 E 332L Microprocessors Lab (Fall 2007) – Lab 5 (Week 7)– Objective: In this lab, you will develop LCD interface routines using the C programming language. Note 1: Use Lab 5’s sof and ptf files. Note 2: KEY0 is processor’s reset. KEY1 (called button1 in Nios II) is level-sensitive button. KEY2 is rising-edge sensitive button. KEY3 is rising-edge with interrupt button. Part 1: High-Level Interface Provided by Altera Hardware Abstraction Layer (HAL1) Interfacing to the Optrex LCD display requires finding, reading and interpreting documentation (data-sheets) supplied by the manufacturer of the LCD display (Optrex) and the developer of the system utilizing the display (Altera). Altera has developed hardware and software to allow integration of the LCD display into their system. The layer of software developed by Altera integrates the Optrex LCD display very nicely into the system that we have been using. The software portion of Altera’s implementation has been accomplished with an interface methodology referred to as HAL. With this implementation the LCD can be utilized with an standard library functions (see figure below). However, with this lab we want to understand just what it takes to communicate with the LCD at the lowest levels. #include <stdio.h> #include "system.h" int main (void) { FILE* LCD; LCD = fopen ("/dev/lcd", "w"); if (LCD == NULL) { fprintf(stderr, "open failed\n"); return 0; } fprintf(LCD, "This is LCD demo\n"); fprintf(LCD, "Altera HAL usage"); fclose (LCD); return 0; } Code 1: Example utilization of LCD with Altera’s HAL device interface 1 A hardware abstraction layer (HAL) is an abstraction layer, implemented in software, between the physical hardware of a computer and the software that runs on that computer. Its function is to hide differences in hardware from most of the operating system kernel, so that most of the kernel-mode code does not need to be changed to run on systems with different hardware [Ref: http://www.wikipedia.org]Page 2 of 9 Part 2: Where to Start? The following is a discussion of some of the issues involved in developing software to work with hardware devices. 2.1: Documentation a. Finding it! Hopefully documentation came with the device. Since Altera developed a HAL interface, they did not feel that it was necessary to provide much information on the low levels of operation. They did supply source code for the HAL implementation, but wading through the details involved with HAL takes a considerable amount of time. Optrex documentation can also be found on the web, but verifying that it matches the device supplied by Altera is problematic. b. Making sense of the documentation found. Often there is too much information - conflicting or extraneous. What’s important? c. Deciding on the applicability or points of view as to which side of device (HW vs. SW), and how to interpret it for the other side of the device d. Understanding the documentation is also a problem. The producers of the documentation generally do not like writing things for consumption by others. This requires that the consumer develop a theory of operation and then prove or disprove that theory. In this lab, we will simplify the documentation issue by providing the following documentation for your use. i. Optrex16207 LCD Controller Core with Avalon Interface (n2cpu_nii51019.pdf) ii. Crystalfontz America, Inc. CFAH1602B-TMC-JP (CFAH1602BTMCJP.pdf) iii. DOT Matrix Character LCD Module User’s Manual (Dmcman_full.pdf) Some of the most important information is provided here. In future labs, you won’t be provided with this amount of details. The goal is to show you what’s important and what’s not. Hopefully this will help you grasp how to process the information on your own next time. Below is a block diagram for a generic Dot matrix LCD panel produced by Optrex. Notice the signals defined on the left side of block diagram since they will be referred to in later diagrams and documentation.Page 3 of 9 2.2: Develop a Model An LCD sometimes comes with an LCD Controller (dealing with voltages and signaling). If an LCD doesn’t come with one, you can get a LCD Controller chip. Since we are in an FPGA environment, we can include such a controller with the Nios II processor inside the FPGA. The available documentation listed in Part 2.1 addresses the operation of the Optrex 16207 LCD Module (blue block in Figure 1) from the perspective of interfacing with the E, RS, RW, DB0-DB7 signals. However, our perspective of interfacing is from the set of four Avalon-MM Registers (pink blocks) implemented by the LCD Controller (yellow block). Use Figure 1 as a guide to translate the available documentation to the perspective of the Altera DE2 FPGA. Data transfer in and out of a NIOS II processor is generally accomplished via the Avalon Bus. In order to keep the diagram simple, the above diagram does not show the details of the Avalon Bus. The Avalon Bus will be covered in the future. To get started, the following structure should be used in your code in order to gain access to the Optrex 16207 LCD display. struct LCD_REGS { unsigned int write_cmd; // RS = 0 Write-Only unsigned int read_cmd; // RS = 0 Read-Only unsigned int write_data; // RS = 1 Write-Only unsigned int read_data; // RS = 1 Read-Only }*LCD = (struct LCD_REGS *)(LCD_BASE | 0x80000000); Before the LCD display can be utilized it must be properly initialized. Sections of the documentation have been included here (review of the full documentation is encouraged) in order to develop software that can initialize the display. The LCD initializing timing is shown in the following figures. Optrex 16207 LCD Module (see Block Diagram 1.6) Altera FPGA – DE2 LCD Controller E RS R/W DB0…DB7 31…8 - Unused Avalon-MM slave interface Registers Command RS=0 31…8 - Unused Status RS=0 31…8 - Unused Data RS=1 31…8 - Unused Data RS=1 7-0 7-0 7-0 7-0Page 4 of 9Page 5 of 9 Detailed information on the method of software initialization as provided by Optrex follows. This is implement in the LCD_init().Page 6 of 9 Use this table to understand the initialization sequence and other functionality of the LCD display. With this understanding you can control the LCD display from Nios. You should use this table to complete the #define in LCD.c.Page 7 of 9 Below is an implementation of


View Full Document

BOISE STATE ECE 332L - Lab 5

Documents in this Course
Load more
Download Lab 5
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lab 5 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lab 5 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?