Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Lecture Slides on Interfacing Input and Output Devices | ECE 3120, Study notes of Microcomputers

Material Type: Notes; Class: Microcomputer Systems; Subject: ECE Elect & Computer Engr; University: Tennessee Tech University; Term: Unknown 2008;

Typology: Study notes

Pre 2010

Uploaded on 07/30/2009

koofers-user-jr6
koofers-user-jr6 🇺🇸

10 documents

1 / 21

Toggle sidebar

Related documents


Partial preview of the text

Download Lecture Slides on Interfacing Input and Output Devices | ECE 3120 and more Study notes Microcomputers in PDF only on Docsity! ECE3120: Computer Systems Chapter 7: Interfacing I/O Devices Jeremy Langston aS Today O Interfacing with LCD 5 Table 7.7 Pin assignment for displays with less than 80 characters Pin No. symbol I/O Function 1 2 3 4 5 6 7 8 9 10 11 12 13 14 VSS VCC VEE RS R/W E DB0 DB1 DB2 DB3 DB4 DB5 DB6 DB7 - - - I I I I/O I/O I/O I/O I/O I/O I/O I/O Power supply (GND) Power supply (+5V) Contrast adjust 0 = instruction input, 1 = data input 0 = write to LCD, 1 = read from LCD enable signal data bus line 0 data bus line 1 data bus line 2 data bus line 3 data bus line 4 data bus line 5 data bus line 6 data bus line 7 A HD44780-Based LCD Kit (2 of 3) 6 Table 7.8 Pin assignment for displays with more than 80 characters Pin No. symbol I/O Function 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 E1 R/W RS VEE VSS VCC E2 N.C I/O I/O I/O I/O I/O I/O I/O I/O I I I - - - I - data bus line 7 data bus line 6 data bus line 5 data bus line 4 data bus line 3 data bus line 2 data bus line 1 data bus line 0 enable signal row 0 & 1 0 = write to LCD, 1 = read from LCD 0 = instruction input, 1 = data input Contrast adjust Power supply (GND) Power supply (+5V) Enable signal row 2 & 3 A HD44780-Based LCD Kit (3 of 3) 7 Table 7.9 HD44780U instruction set Instruction Code RS R/W B7 B6 B5 B4 B3 B2 B1 B0 Description Executiontime Clear display Cursor home Entry mode set Display on/off control Cursor /display shift Function set Set CGRAM address Set DDRAM address Read busy flag and address counter Write CGRAM or DDRAM Read from CGRAM or DDRAM Clears display and returns cursor to the home position (address 0). Returns cursor to home position (address 0). Also returns display being shifted to the original position. DDRAM contents remain unchanged. Set cursor move direction (I/D), specifies to shift the display (S). These operations are performed during data read/write. Sets on/off of all display (D), cursor on/ off (C) and blink of cursor position character (B). Sets cursor-move or display-(S/C), shift direction (R/L). DDRAM contents remains unchanged. Sets interface data length (DL), number of display line (N) and character font (F). Sets the CGRAM address. CGRAM data is sent and received after this setting. Sets the DDRAM address. DDRAM data is sent and received after this setting. Reads busy flag (BF) indicating internal operation is being performed and reads CGRAM or DDRAM address counter contents (depending on previous instruction). Writes data to CGRAM or DDRAM. Reads data from CGRAM or DDRAM. 1.64 ms 1.64 ms 40 μs 40 μs 40 μs 40 μs 40 μs 40 μs 0 μs 40 μs 40 μs 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 1 BF 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 1 DL 0 0 0 1 S/C N 0 0 1 D R/L F 0 1 I/D C * * 1 * S B * * CGRAM address DDRAM address CGRAM/DDRAM address write data read data HD44780 Commands (1 of 4) 10 Table 7.12 Register selection RS R/W Operation 0 0 1 1 0 1 0 1 IR write as an internal operation (display clear, etc) Read busy flag (DB7) and address counter (DB0 to DB6) DR write as an internal operation (DR to DDRAM or CGRAM) DR read as an internal operation (DDRAM or CGRAM to DR) Registers of HD44780 The HD44780 has two 8-bit user accessible registers: instruction register (IR) and data register (DR). To write data into display data RAM or character generator RAM, the MCU writes into the DR register. The address of the data RAM should be set up with a previous instruction. The DR register is also used for data storage when reading data from DDRAM or CGRAM. The register selection is shown in Table 7.12. The HD44780 has a busy flag that is output from the DB7 pin. The HD44780 uses a 7-bit address counter to keep track of the address of the next DDRAM or CGRAM location to be accessed. 11 HD44780 Instructions (1 of 3) Clear display Writes 0x20 (space character) to all DDRAM locations Sets 0 to the address counter (return cursor to upper left corner of the LCD) Sets increment mode Return home Sets address counter to 0 DDRAM contents not changed Entry mode set Sets incrementing or decrementing of the DDRAM address Controls the shifting (shifts if S bit = 1) of the display Display on/off control Turns on/off display Turns on/off cursor Turns on/off cursor blinking 12 Table 7.13 LCD Shift function S/C R/L Operation 0 0 1 1 0 1 0 1 Shifts the cursor position to the left. (AC is decremented by 1) Shifts the cursor position to the right. (AC is incremented by 1) Shifts the entire display to the left. The cursor follows the display shift. Shifts the entire display to the right. The cursor follows the display shift. Cursor or display shift This function shifts the cursor position to the right or left without writing or reading display data. The shifting is controlled by two bits as shown in Table 7.13. Function set Sets the interface length (DL bit) to be 4- or 8-bit Selects the number of lines (N bit) to be one or two lines Selects character font (F bit) to be 5 × 8 or 5 × 10 HD44780 Instructions (2 of 3) 15 Procedure to send a command to the IR register Step 1 Pull the RS and the E signals to low. Step 2 Pull the R/W signal to low. Step 3 Pull the E signal to high. Step 4 Output data to the output port attached to the LCD data bus. One needs to configure the I/O Port for output before writing data to the LCD kit. Step 5 Pull the E signal to low and make sure that the internal operation is complete. 16 The procedure for writing a byte to the LCD data register Step 1 Pull the RS signal to high. Step 2 Pull the R/W signal to low. Step 3 Pull the E signal to high. Step 4 Output data to the I/O port attached to the LCD data bus. Step 5 Pull the E signal to low and make sure that the internal operation is complete. These procedures need to be repeated once for an LCD kit with 4-bit interface. 17 lcdPort equ PTH ; LCD data port lcdCtl equ PTK ; LCD control port lcdE equ $80 ; E signal pin (PK7) lcdRW equ $20 ; R/W signal pin (PK5) lcdRS equ $10 ; RS signal pin (PK4) ; the command is contained in A cmd2lcd bclr lcdCtl,lcdRS+lcdRW ; select instruction register and Write bset lcdCtl,lcdE ; pull the E signal high staa lcdPort ; send the command, along with RS, E signals nop nop bclr lcdCtl,lcdE ; pull the E signal low bset lcdCtl,lcdRW ; pull R/W to high ldy #1 ; adding this delay will complete the internal jsr delayby50us ; operation for most instructions rts Write a function to send a command to the LCD kit Most LCD commands are completed in 40 ms. If the function waits for 40 ms after performing the specified operation, then most commands will be completed when the function returns. The assembly code for the 8-bit interface is as follows: 20 Function to output a string terminated by a NULL character The string to be output is pointed to by index register X. Example 7.7 Write an assembly program to test the previous four subroutines by displaying the following messages on two lines: hello world! I am ready! puts2lcd ldaa 1,x+ ; get one character from the string beq done_puts ; reach NULL character? jsr putc2lcd bra puts2lcd done_puts rts 21 #include "hcs12.inc" lcdPort equ PTH ; LCD data pins (PH7~PH0) lcdDIR equ DDRH ; LCD data direction port lcdCtl equ PTK ; LCD control port lcdCtlDir equ DDRK ; LCD control port direction lcdE equ $80 ; E signal pin lcdRW equ $20 ; R/W signal pin lcdRS equ $10 ; RS signal pin org $1500 lds #$1500 ; set up stack pointer jsr openlcd ; initialize the LCD ldx #msg1lcd jsr puts2lcd ldaa #$C0 ; move to the second row jsr cmd2lcd ; " ldx #msg2lcd jsr puts2lcd swi msg1lcd fcc "hello world!" dc.b 0 msg2lcd fcc "I am ready!" dc.b 0 #include “c:\miniide\delay.asm" ; include delay routines here ; include the previous four LCD functions
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved