Home

Lab 5: LCD Interface

image

Contents

1. Dragon12 User s Manual LCD 107 LCD module datasheet HD44780 LCDC datasheet Pre Lab 1 Collect your own copies of the schematic user manual and datasheets as listed in the materials needed section above These documents should be available on the resources page of the course website 2 Review the LCD module interface diagram shown in figure 1 below Referring to the Dragon12 schematic pg 4 add the LCD PORT J12 pin numbers just outside its box in figure 1 Next refer to the LCD module datasheet and add the LCD module pin numbers just outside its box in figure 1 Q1 Do you think this correlation was by design or just coincidence Note this is an informal but industry standard interface Dragoni2 LCD PORT LCD Module Fig 1 LCD interface Lab 5 LCD Interface Page 1 3 Review the HD44780 datasheet and answer the following questions Q2 The HD44780 is an example of LSI IC What is LSI an acronym for Review the HD44780 block diagram to see why this is so Q3 Review the table of pin functions How many total pins does the HD44780 have Q4 How many characters are provided for by the internal character generator ROM Refer to table 4 and note the relationship between the character pattern codes and the ASCII table Q5 Review the section on the HD44780 s Functional Description a How many registers does the LCDC have b Name the ones that are directly programmer accessible c What is the purp
2. d next page Lab 5 LCD Interface Page 3 Lab 5 Project Assignment Create and demonstrate to the instructor a digital stop watch using the EVB the LCD module and software driver and your ingenuity At a minimum your solution must track seconds and tenths of seconds Specifications are as follows a use a pushbutton run switch between an appropriate input port and ground b display a greeting and instructions to the user via the Terminal connection not LCD display a project title on line 1 of the LCD ex Ultimate Watch call a subroutine that you create to display the current elapsed time initially zero on the far left of line 2 in an appropriate format ex 00 0 Note the LCD driver includes a function for decimal output e wait for the run switch to go active implement the following loop delay 100 ms use the millisecond delay subroutine from previous labs increment the appropriate elapsed time counters tenths seconds etc output the updated elapsed time using your above subroutinet repeat this loop if the run switch is still active g display an exit message to the user via the Terminal connection c d tYour time output subroutine should first reposition the LCD cursor to the beginning of line 2 Deliverables Submit a laboratory packet including 1 A cover page including course number amp title lab number amp title date submitted lab team member names and
3. clear display LCDHOMECU 2 home cursor LCDGOTORC 73 goto row column LCDWRCMD 74 write LCD instruction LCDWRCHR 75 write LCD data character LCDWRSTR 76 write character string LCDWRDEC 7 write byte as decimal LCDWRHEX2 8 write byte as 2 hex digits LCDWRHEX4 9 write word as 4 hex digits LCDJMPTBL length of jump table in bytes 6 number of table entries 33 lst reset code must delay 4 1ms after sending ibbles must be delay 40us min each after sending 32 3rd 4th reset code 28 74 bit mode 2 line 5X7 dot 06 cursor INCrement disable display shift SOC display on cursor off no blinking 01 clear display memory set cursor to home pos ize display LCDPORT initial outputs all low SFF LCDDDR make LCD port all outputs LCDITBL point X to LCD initialization table Xt get length of table iX get init code from table move top nibble into position LCDWRNIB send 4 bit nibble to LCD Delay5ms 5ms delay between all table values move bottom nibble into position LCDWRNIB send 4 bit nibble to LCD Delay5ms 5ms delay between all table values B LCDILOOP display to blanks and home cursor 1 clear display instruction LCDWRCMD n cursor to home position 2 return home instruction LCDWRCMD Delay5MS Lab 5 LCD Interface Page 6 rts LCDGOTORC Stacked Xhi is target row For a 2 li move cursor to ne LCD row Goch eg x while C0 FF are fo
4. ko K KK k k kok ko k kok kok kok kok kok kok k S12 LCD D Ro ak ME eR by J Sumey The following routines collectively form a driver to control a smart Liquid Crystal Display as interfaced to the DRAGON12 EVB on port K This driver is for any LCD module with an on board Hitachi HD44780 LCD II or equivalent controller The 44780 requires two locations for its Instruction Register IR and Data Register DR All LCD functions are user callable via the single entry point LCD using a function code passed in accumulator A Function parameters when any are passed in AccB and or register X This driver is code only no memory resident variables are required Example usage ldaa LCLEAR A clear display function code jsr LCD clear display ldaa LWRDEC A decimal output function code ldab 123 decimal number to output JSE LCD output decimal number Note that the LINIT function must be invoked to initialize the LCD before any other function will work This should part of your one time initialization code To add this driver to your main program insert the following line before your END statement include LCDdriver asm Interfacing details PK7 LCD R W Read Write not used PK5 LCD DB7 PK4 LCD DB6 PK3 LCD DB5 PK2 LCD DB4 PK1 LCD EN Enable PKO LCD RS Register Select 0 control 1 data Revision history 10 Feb 1990 jss initial writing 02 Dec 2003 jss revised for Axiom CME11 board 11 Oct 200
5. 8 JSS additional documentation added 20 Oct 2011 jss revised for DRAGON12 EVB FF FF FF FF FF FF FF FF FF HF HF FF FF FF FF FF FF FF FF FF FF HF F FF FF 4 FF FF FF FF FF FF FF FF FF FF FF FF HF HF FF FH HF OF kK kK kK kK kK K K KK KK KK KK KK KK K KK KK KK K KK KK KK K KK LCDPORT EQU 0032 PFORTE LCDDDR EQU 0033 DDRK RSBIT EQU 1 bit mask for RS ENBIT EQU 2 for ENable pulse RWBIT EQU 80 for Read Write line KKEKKKKKKKKKKKKKKKKK KKK KKK KK KKKK KKK KKK KKK KKK KKK KKK KKK KKK KKKKKKKKKKKKKKKKKKKK LCD DRIVER ROUTINE FUNCTION CODES E KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK The following definitions define symbolic names for LCD functions available in this driver The desired function code is loaded into AccA before a JSR to LCD is executed Some functions additionally require other parameters in AccB and or X LINIT EQU 0 initialize display function LCLEAR EQU HF Cclear display function LHOME EQU 2 home cursor function LGOTO EQU 3 move cursor to row Xhi column Xlo LWRCMD EQU 4 write LCD command in B LWRCHR EQU 5 write character in B LWRSTR EQU 6 write null terminated string X points to LWRDEC EQU 7 write byte in B as decimal LWRHEX2 EQU 8 write byte in B as 2 hex digits LWRHEX4 EQU 9 write word in X as 4 hex digits KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK x LCD DRIVER ROUTINE MAIN ENTR
6. CET335 Microprocessor Interfacing Lab 5 LCD Interface Bus Attached Peripheral Introduction In this lab you will learn the interface and operation of a bus attached peripheral in other words a controller IC that normally connects directly to the system buses The controller you will learn about is the Hitachi HD44780 Liquid Crystal Display Controller LCDC as found on board the LCD module used in this lab You will become familiar with both the hardware interface and the software required to control and operate the display via the LCDC Because the software for this device is somewhat more complex than previous labs you will be given a collection of low level control routines in the form of a software driver and you will learn how to use this driver from your application program Of particular note in this lab is the fact that because the S12 MCU on board the Dragon12 EVB does not have external buses you will see that all LCD interfacing is done via PORTK I O lines Objectives e to provide the student an exposure to a complex peripheral controller IC as used for LCD applications and of its datasheet e to demonstrate the interface and synchronization of a bus attached peripheral controller e to demonstrate the software control of a peripheral controller IC e to demonstrate a single point entry method of software driver implementation Materials needed e DRAGON12 EVB e LCD module preinstalled e pushbutton switch Dragon12 schematic
7. Y x Lab 5 LCD Interface Page 5 KKKKKKKKKKKKKKKKKKKK On entry to LCD v is used after do corresponding rou only a single ent All registers ex F ORG LCD pshy pshx pshd asla cmpa bhs ldy exg ldy jsr LCDEX puld pulx puly rts Jump Table con LCDJMPTBL FDB DB DB DB DB DB DB DB DB DB LCDTBLLEN EQU EF F F F p E F F F F LCDITBL FCB FCB all following 10 n FCB FCB FCB FCB FCB ee TNE TEC initial LCDINIT clr movb ldx ldab LCDILOOP ldaa psha rora rora lbsr LOSr ula ola ola LOSr lbsr dbne rts 5K bTO LCDCLEAR clear LCDCLEAR ldaa bsr LCDHOMECU retur LCDHOMECU ldaa bsr lbsr KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK ia JSR AccA contains the desired function number and ubling as an offset into a vector table to call the tine This works much like a computed GOSUB so that ry point for all LCD functions is needed cept CC are preserved for the caller 1100 jor where ever you want optional save caller s registers double function number LCDTBLLEN is function number invalid LCDEX return immediately if not LCDJMPTBL point Y to jump table A B swap A amp B B Y get address of routine 0 Y call function handler restore caller s registers jand return to caller tains 2 byte address for each function handler LCDINIT 0 initialize display LCDCLEAR 1
8. eturn write byte in AccA as 2 hex digits LCDWRHEX1 S0F 90 940 LCDWRCHR save original byte move hi nibble to lo output hi nibble recall amp output lo half mask off top nibble now A 90 S9F 7 90 99 or 00 05 Carry 7 D0 SD9 or 41 46 7 30 39 or 41 46 gt ASCII output as ASCII amp return write a character string to LCD 0 X LCDWRSEX LCDWRCHR LCDWRSTR LCDPORT R LCDWRBYTE write a data byte to LCD SBIT ts to beginning of null terminated string pick exit up a chr from string if end of string else output it bump string ptr 7 repeat 7set RS bit to LCD high Lab 5 LCD Interface Page 7 WRCMD write an instruction to LCD LCDWRCMD bclr LCDPORT RSBIT set RS bit to LCD low 7 amp fall thru to LCDWRBYTE k lowest level LCD output routines using I O port LCDWRBYTE output AccA value to LCD in 4 bit mode LCDWRBYTE psha save original value rora move top nibble into position rora bsr LCDWRNIB send it pula recall original value rola move low nibble into position rola bsr LCDWRNIB send it bsr Delay50us minimal output delay rts LCDWRNIB output middle 4 bits of AccA to LCD LCDWRNIB anda 3C extract middle 4 bits to write psha save on stack ldaa LCDPORT read current output pattern anda 5C3 clear middle 4 bits oraa SPF turn on needed bits staa LCDPORT send to LCD LCDENPLS send Enable pu
9. lse to LCD LCDENPLS psha preserve A bset LCDPORT ENBIT drive enable line high ldaa 8 count for lus delay dbne A hold it a while belr LCDPORT ENBIT return to low pula rts Delay5ms delay 5 millisecond via software x assumes F 24 MHz and no interrupts K all registers preserved for caller Delay5ms pshx 2 preserve registers used here ldx 39996 2 iterations for 5ms dbne X 73 39996 loops 3 loop 119988 pulx 3 recover used registers rts 5 119988 12 120000 5ms Delay50us pshx 2 preserve registers used here ldx 396 2 iterations for 50us dbne X 3 396 loops 3 loop 1188 pulx 3 recover used registers rts 5 1188 12 1200 50us KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK End of LCD Driver x KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK Lab 5 LCD Interface Page 8
10. om the caller Q10 How does this driver synchronize output writes with the LCDC At this point you should be properly prepared for working with the actual LCD module in lab Show your completed pre lab to the instructor to proceed Pre Lab Instructor Signoff Ot _ Lab 5 LCD Interface Page 2 Lab Procedure 8 You have noticed that the Dragon12 EVB contains a backlit 16x2 LCD module preinstalled Thus no actual attachment of an LCD is required as we will be using this display Note that the Dragon12 s J5 header does support an optional external LCD you are welcome to try connecting a larger LCD such as the 2x40 modules we have in lab 9 Although we could repeat step 6 on the Dragon12 s LCD it would be unduly tedious because the LCD s bus interface is connected to the S12 s general purpose I O port K Therefore it s now time for more neat software Obtain a copy of the LCDdriver asm file as shown in listing 1 to your work directory Using the template asm file as before create an S12 program that will output a message of your choice to the LCD At a minimum your program should a invoke the LINIT function to initialize the LCD module b invoke the LWRSTR function to output your message to the LCD c use the include assembler pseudo op before your END directive as documented in the driver header You may proceed with the last part of this lab only after successfully completing this step cont
11. ose of the Busy Flag BF d How many register locations in the memory map does the LCDC require Q6 Refer to the LCDC Instruction chart in table 6 a How many different operations does the LCDC support ___ b The function set instruction code for 8 bit transfers 2 line display and 5x8 characters is ____ 4 Review the Dragon12 User s Manual table 1 1 and section 4 5 and note how the LCD is interfaced to the S12 s port K lines Note that in the absence of system buses we will have to drive these pins programmatically to control the LCD 5 Return to the HD44780 data sheet and review table 13 to learn how 8 bit operation for a 2 line display is conducted Review figure 23 to become familiar with the required initialization sequence 6 Goto Dincer s LCD Simulator page http www dinceraydin com djlcdsim djlcdsim html and perform the appropriate steps to display your name on the simulated LCD Don t forget the required initialization sequence from figure 23 of the HD44780 data sheet By accomplishing this you will understand precisely what the processor must do to produce LCD output via the LCDC Cool stuff no 7 Review the LCDdriver asm listing as provided with this lab and answer the following questions Q7 This LCD driver as given has a single entry point subroutine named Q8 How does the entry point routine determine what specific function the caller wants Q9 How does this driver accept additional parameters fr
12. r line 1 LCDGOTORC ldaa 4 8 ldab 30100000 mul ldaa 5 S aba oraa 31000000 bra LCDWRCMD LCDWRDEC 0 0 column Xlo is column RAM addresses 80 SBF are for line 0 0 39 pick row from stack B 2 6 calculate row address pick column from stack add row 64 to col make set RAM addr go write it amp return command write byte in AccA as unsigned decimal number LCDWRDEC tab clra LCDWRDEC2 ldx 10 idiv pshb xgdx ldx 10 idiv pshb xgdx tba beq LCDWRDEC3 bsr LCDWRHEX LCDWRDEC3 pula tsta bne LCDWRDEC4 tstb beq LCDWRDEC5 LCDWRDEC4 bsr LCDWRHEX LCDWRDEC5 pula bra LCDWRHEX x LCDWRHEX4 write word as stacked X is 16 bit word LCDWRHEX4 ldd 4 8 bsr LCDWRHEX2 tba LCDWRHEX2 LCDWRHEX2 psha lsra lsra lsra lsra bsr pula LCDWRHEX1 anda adda daa adca daa bra LCDWRSTR X poin LCDWRSTR ldaa beq bsr inx bra LCDWRSEX rts WRCHR LCDWRCHR bset bra 7B number to output X divisor 7D D rem 10 save units 7exchange rem amp quotient now get tens xX D DIV 10 save tens get hundreds in D move to A amp setup Z suppress if 0 output hundreds digit restore tens was it 0 poutput it if not was hundreds 0 suppress tens if so output tens digit restore units digit poutput it amp return 4 hex digits to output pick X from stack output A as hex output B as hex amp r
13. signatures 2 A lab write up including the Project Requirements and a Description of Solution These sections should be clearly titled 3 A section titled Achievement of Course Outcomes describing how this lab contributed to fulfillment of the selected two program outcomes below Each team member must complete this section individually according to your major CET or EET 4 Documentation of software design development i e flowcharts 5 A properly commented error free assembly listing of your program per website instructions Total point value 20 Selected program outcomes By the time of graduation Computer Engineering Technology students will demonstrate CET Oc1 The knowledge skills techniques and applications of modern tools in the computer engineering technology discipline CET Oc3 Technical problem solving skills including the ability to identify problems use appropriate laboratory and test equipment conduct experiments gather data analyze data and produce results By the time of graduation Electrical Engineering Technology graduates will demonstrate EET Oc1 The knowledge skills techniques and application of modern tools in the electrical engineering technology discipline EET Oc10 The ability to analyze design and implement analog and microprocessor systems through a blend of theoretical and practical methods Ot _ Lab 5 LCD Interface Page 4 Listing 1 LCD driver kK kK kK kK kK kK K K K K K kok

Download Pdf Manuals

image

Related Search

Related Contents

  multiclin pro i multiclin pro ii multiclin pro i multiclin  Skil 7120MA  Lire un extrait  MANUEL D`UTILISATION  Radio Shack 15-2160 User's Manual  USER`S MANUAL  ExtendAir® eMIMO™ Digital Microwave Radios Quick Start Guide  Manuale del telefono Cisco Unified IP Phone 7960G  

Copyright © All rights reserved.
Failed to retrieve file