EET 2261 Unit 12 Controlling LCD and Keypad

Slides:



Advertisements
Similar presentations
INDIVIDUAL PROJECT BY R.KARTHIKMANOJ
Advertisements

Zhongxing Telecom Pakistan (Pvt.) Ltd
BASIC SKILLS AND TOOLS USING ACCESS
Floyd, Digital Fundamentals, 10 th ed EET 2261 Unit 7 Indexed Addressing Mode Read Mazidi, Chapter 6. Homework #7 and Lab #7 due next week. Quiz next week.
Mehdi Naghavi Spring 1386 Operating Systems Mehdi Naghavi Spring 1386.
EET 2261 Unit 13 Stepper Motors and Servos
IR Communication Materials taken from a variety of sources including IR Remote for the Boe-Bot by Andy Lindsay.
Registers and Decoder.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 12 – Security Panel Application Introducing.
How to Import a Survey from SPS Format
Lab # 03- SS Basic Graphic Commands. Lab Objectives: To understand M-files principle. To plot multiple plots on a single graph. To use different parameters.
TCP/IP Protocol Suite 1 Chapter 18 Upon completion you will be able to: Remote Login: Telnet Understand how TELNET works Understand the role of NVT in.
Reporting Services – Data Driven Subscriptions
Lab 9: Matrix Keypad : ”No Key Press” Analysis Slide #2 Slide #3 ”Press and Hold Key 5” Analysis.
PRESS C7000/C7000P/C6000 Color Density Control Color Balance
EET 2261 Unit 14 INCOMPLETE Analog-to-Digital Conversion (ADC) & Digital-to-Analog Conversion (DAC)  Read.  Homework #13 and Lab #13 due next week. 
TK2633 Introduction to Parallel Data Interfacing DR MASRI AYOB.
EET 1131 Unit 10 Flip-Flops and Registers
Microprocessor and Microcontroller
EET 2261 Unit 8 Seven-Segment Displays; S19 Records; System Clocks
EET 2261 Unit 9 Interrupts  Read Almy, Chapters 17 – 19.  Homework #9 and Lab #9 due next week.  Quiz next week.
EET 2261 Unit 13 Controlling Stepper Motors and Servos  Read Almy, Chapter 21.  Lab #13 due next week.  Final Exam next week.
EE 316 Computer Engineering Junior Lab Word Mastermind.
Chapter 7 Programming with DOS and BIOS Function Calls Objectives: The use of DOS and BIOS function call How to read the PC’s keyboard How to send text.
Embedded Systems 7763B Mt Druitt College of TAFE Electrical Engineering Lesson 2 LCD Display Interfacing.
OUTLINE WHAT ? HOW ? WHY ? BLUEPOST Poster and Message Content Specified by the User Displaying the Poster Content on a Monitor Sending Messages to.
Getting the O in I/O to work on a typical microcontroller Ideas of how to send output signals to the radio controlled car. The theory behind the LED controller.
Getting the O in I/O to work on a typical microcontroller Activating a FLASH memory “output line” Part 1 Main part of Laboratory 1 Also needed for “voice.
EET 2261 Unit 2 HCS12 Architecture
EE 316 Computer Engineering Junior Lab Digital Hangman.
Lecture – 7 Basic input and output
Embedded Programming and Robotics Lesson 9 Keypad and LCD Display 1.
16x2 LCD Module on DE2-115 數位電路實驗 TA: 吳柏辰 Author: Trumen.
Parallel Ports of PC Methods of interfacing Examples.
Did you know that the keyboard on a typical computer system is actually a computer itself? Your basic Windows keyboard At its essence, a keyboard is a.
CHARACTERS Data Representation. Using binary to represent characters Computers can only process binary numbers (1’s and 0’s) so a system was developed.
Overview What kind of LCD Interfacing the LCD Displaying Text and Numbers Common Issues.
Digital Outputs LCD Display
Agenda What is Computer Programming? The Programming Process
Serial Communication Lab 12 Module M21.1. Asynchronous Serial I/O ASCII code 54H = (“T”) sent with odd parity.
ORG ; FOUR INT 21H and INT 10H Programming and Macros Dec Hex Bin
LCD Interfacing.
Embedded Systems 7763B Mt Druitt College of TAFE Electrical Engineering Lesson 2 LCD Display Interfacing.
EE 316 Computer Engineering Junior Lab Project 2 Digital Yahtzee.
Department of Electronic & Electrical Engineering LCD character display (parallel interface). How to interface a LCD character display to a PIC.
KEYBOARD INTERFACING Keyboards are organized in a matrix of rows and columns The CPU accesses both rows and columns through ports. ƒTherefore, with two.
1 Week # 4 Introduction to PDM PDM is a workbench environment that lets programmers and system operators navigate the three levels of the AS/400’s object-based.
Lab. 1 – GPIO Pin control Using information ENEL353 and ENCM369 text books combined with Blackfin DATA manual.
Vishwakarma government engineering college Prepare by. Hardik Jolapara( ) LCD Interfacing with ATmega16.
LED AND KEYBOARD INTERFACING PREPARED BY :- PREPARED BY :- RAVAL AKASH ( ) RAVAL AKASH ( ) PATEL HARDIK ( ) PATEL HARDIK.
CEng3361 CENG 336 INT. TO EMBEDDED SYSTEMS DEVELOPMENT Spring 2011 Recitation 06.
EET 1131 Unit 4 Programmable Logic Devices
EET 2259 Unit 13 Strings and File I/O
Peripherals – Keypad The Keypad provides a simple means of numerical data or control input. The keys can be attributed whatever data or control values.
Fundamentals of Computer Engineering
LCD AND KEYBOARD INTERFACING
LCD and Keyboard Interfacing
DIGITAL CALCULATOR USING 8051
Microprocessor and Assembly Language
EET 2261 Unit 11 Controlling LCD and Keypad
LCD and Keyboard Interfacing
EET 2261 Unit 11 Controlling LCD and Keypad
LCD and Keyboard Interfacing
EET 2261 Unit 14 INCOMPLETE Analog-to-Digital Conversion (ADC) & Digital-to-Analog Conversion (DAC) Read. Homework #13 and Lab #13 due next week. Quiz.
LCD and Keyboard Interfacing
LCD and Keyboard Sepehr Naimi
EET 2261 Unit 12 Controlling Stepper Motors and Servos
EET 2261 Unit 8 Seven-Segment Displays
EET 2259 Unit 13 Strings and File I/O
LCD AND KEYBOARD INTERFACING
Presentation transcript:

EET 2261 Unit 12 Controlling LCD and Keypad Read Almy, Appendix E. Homework #12 and Lab #12 due next week. Quiz next week. Handouts: Custom Character practice sheet, Keypad Scan practice sheet

Liquid-Crystal Display The Dragon12 board has a liquid-crystal display (LCD) module that lets the programmer display text messages to the user. Datasheet for SHZJ-A162A LCD module The LCD module contains an LCD panel and an LCD microcontroller that has its own memory distinct from the HCS12’s memory. This microcontroller handles most of the work of displaying characters on the LCD panel. Datasheet for S6A0069 LCD controller

Dimensions of Our LCD Panel The S6A0069 can control a variety of LCD panels. Variations include: Number of lines (1 or 2) Number of characters per line (16, 20, 40… ) Size of matrix of dots that make up a character (5x8, 5x11). Our panel has two lines of 16 characters per line, with a 5x8 matrix of dots for each character. Our programs must contain initialization code to configure the S6A0069 for the panel we’re using.

5x8 Dot Matrix Example The figure to the right shows which of the dots in the 5x8 matrix are lit to display an A. Normally we won’t have to worry about this level of detail. We’ll just send the ASCII code for A to the LCD module, and it will take care of lighting up the correct dots. But we do have the ability to create custom characters if we wish. Contrast with 7-segment displays, where we had to turn on or off each individual segment.

List of LCD Commands See Table 7 on page 16 of the S6A0069 datasheet for a list of all commands that the LCD recognizes. Most of these commands are used for initialization, such as specifying: Whether our LCD panel has 1 line or 2. Whether it displays characters with a 5x8 dot matrix or a 5x11 matrix. Whether we want the cursor to be visible. Whether we want the cursor to blink.

Typical Initialization Code

I/O Pins on the LCD Module Figure and table from the SHZJ-A162A datasheet.

LCD Connections on Dragon12 LCD is connected to the HCS12’s Port K. The LCD’s R/W pin is permanently grounded (through jumper J5), placing the LCD permanently in write mode. Otherwise we’d need two ports to control the LCD. Using only a 4-bit bus saves us pins, but makes our lives a bit harder. Figure from page 4 of the Dragon12 schematic diagrams. Only 4 of the 8 bits on the LCD’s data bus are connected to the HCS12. This is a common practice, to save pins.

Command or Data? We can send two kinds of things to the LCD module: Commands, such as: Clear the display. Move cursor to the 4th position on line 1. Make the cursor blink. Data, which is ASCII code for text to be displayed, such as “Rock on!” We must set the RS (Register Select) bit LOW when we’re sending a command, and set it HIGH when we’re sending data.

Executing the Command or Data We must hold the EN line (which connects to the LCD module’s E pin) LOW most of the time. After we’ve set the RS line to its correct level, and put a command or data on the bus, we must send a brief LOW-to-HIGH-to-LOW pulse on the EN line. This pulse is what actually tells the LCD module to perform the action we’ve requested.

Steps for Sending a Command to the LCD To send a command (such as Clear Screen) to the LCD, a program must: Store the upper nibble of the command byte to Port K bits 2-5, and set Port K bit 0 LOW. (Bit 0 tells whether we’re sending a command or data.) Pulse Port K bit 1 HIGH-then-LOW. Store the lower nibble of the command byte to Port K bits 2-5 , and set Port K bit 0 LOW.

Sample Code For Sending a Command (Assumes command byte is in Accumulator A)

Steps for Sending Data to the LCD To send data (such as the character H) to the LCD, a program must: Store the upper nibble of the data byte to Port K bits 2-5, and set Port K bit 0 HIGH. Pulse Port K bit 1 HIGH-then-LOW. Store the lower nibble of the data byte to Port K bits 2-5 , and set Port K bit 0 HIGH. Almost the same as the steps for sending a command.

Code For Sending Data You can easily modify the SendCommand subroutine (on the slide before the previous one) to create a SendData subroutine.

Sample Code for Displaying a Character Assuming we’ve set everything up correctly with our initialization code, we can send text to be displayed. The code below positions the cursor and then sends an H.

ASCII Code As defined in the 1960’s, ASCII code is a 7-bit code, whose values range from $0 to $7F (or %0111 1111). Thus it contains the codes for 128 characters, as shown on page 375 of our textbook. The first 32 codes (from $0 to $1F) and the last code ($7F) were originally defined as non-printable control codes to control Teletype equipment. Most of these control codes are obsolete in today’s world.

Extending the ASCII Code Since the 1960’s, manufacturers have extended the ASCII code in two ways: By redefining some of the now-obsolete control codes. By extending the code from 7 bits to 8 bits, thus allowing for an additional 128 characters. One such widely used extension is the one that IBM used on its PCs: see http://en.wikipedia.org/wiki/Code_page_437. Our LCD module assigns different characters to these codes.

Our LCD Module’s Character Set On our LCD module: Codes $00 through $07 are reserved for user-defined characters. Codes $08 through $1F are unused. Most of the codes in the range $20 through $7F agree with the standard ASCII set. Codes $80 through $9F are unused. Codes $A0 through $FF produce special characters.

Dragon12-Plus2 Keypad Our Dragon12-Plus2 board has a keypad with 16 switches (or keys). The switches are arranged in a 4-by-4 matrix. Each row of this matrix is attached to one of the Port A pins PA4 to PA7. Each column of the matrix is attached to one of the Port A pins PA0 to PA3. See diagram on next slide. Exploits a clever trick that lets us read all 16 keys with only 8 I/O pins instead of 16.

Dragon12 Keypad Connections Figure from p. 26 of Dragon12-Plus2 manual.

Different from the Textbook’s Keypad Caution: the keypad connections on our Dragon12-Plus2 board are different from the connections assumed in the textbook’s discussion (as shown in the figures on page 340 of the textbook). Therefore, while the general principles of the book’s discussion do apply to our keypad, the details are different.

Configuring the Keypad To use the keypad, we must first configure it: Configure Port A pins 0 to 3 as outputs. (These are the pins connected to the keypad columns.) Configure Port A pins 4 to 7 as inputs. (These are the pins connected to the keypad rows.)

Identifying Which Key is Pressed General idea: Make one column output HIGH at a time (while other columns are LOW), and then check each row input to see if any of them are HIGH. If it is, then we know which key is being pressed. See next slide for modified version of keyboard scan routine from p. 27 of Dragon12 manual. Do keypadScan practice sheet.

Keyboard Scan Routine Modified from p. 27 of Dragon12 manual. Set PA0 high and PA1, PA2, PA3 low, and then test PA4-PA7. If no key is pressed, PA4-PA7 remain low. If PA7 = high, then key 12 is pressed. If PA6 = high, then key 8 is pressed. If PA5 = high, then key 4 is pressed. If PA4 = high, then key 0 is pressed. Set PA1 high and PA0, PA2, PA3 low, and then test PA4-PA7. If PA7 = high, then key 13 is pressed. If PA6 = high, then key 9 is pressed. If PA5 = high, then key 5 is pressed. If PA4 = high, then key 1 is pressed. Set PA2 high and PA0, PA1, PA3 low, and then test PA4-PA7. If PA7 = high, then key 14 is pressed. If PA6 = high, then key 10 is pressed. If PA5 = high, then key 6 is pressed. If PA4 = high, then key 2 is pressed. Set PA3 high and PA0, PA1, PA2 low, and then test PA4-PA7. If PA7 = high, then key 15 is pressed. If PA6 = high, then key 11 is pressed. If PA5 = high, then key 7 is pressed. If PA4 = high, then key 3 is pressed. Modified from p. 27 of Dragon12 manual.

Code That Implements the Keyboard Scan Routine Download the code from http://people.sinclair.edu/nickreeder/eet2261/labs/lab12KeypadNumberToLEDs.txt .

Key Numbers Versus Key Labels On previous slides we’ve been referring to keys by their numbers, starting with key #0 in upper left corner of keypad and ending with key #15 in lower right corner. Don’t confuse these key numbers with the labels on the keys, which are shown at right.