1 / 15

Device Drivers – LCD Display

Device Drivers – LCD Display. Task Plan. You will create a device driver for a Liquid Crystal Display (LCD) . You will learn have some more practice with useful assembler commands. Conceptual Design . We want to construct :. Watch out +5V on PIN 1. 8-bit data bus. RS,R/W,E.

fai
Download Presentation

Device Drivers – LCD Display

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Device Drivers – LCD Display Jordan Nash - Microprocessor Course

  2. Task Plan You will create a device driver for a Liquid Crystal Display (LCD). You will learn have some more practice with useful assembler commands. Jordan Nash - Microprocessor Course

  3. Conceptual Design We want to construct : Watch out +5V on PIN 1 8-bit data bus RS,R/W,E ATmega128 Board LCD INTERFACE LCD DISPLAY POWERTIP PORTD Buttons Jordan Nash - Microprocessor Course

  4. Useful things to know • The LCD board is viewed as an external SRAM From the ATMEL STK300+ board. • The External SRAM option must be enabled: • Set bits on MCUCR • PORTA is used for address higher bits and data • PORTC is used for the address lower bits. Jordan Nash - Microprocessor Course

  5. MCU Control Register ; ******* External SRAM setup MCUCR ******* ; ; we want readandwriteactivity on RE WR – Bit 7 Set ; enable the wait state – Bit 6 Set ; Idle Mode – bit 5 Clear ; ldir16, $C0; Load MCUCR Bits out MCUCR, r16 ; Write to MCUCR Jordan Nash - Microprocessor Course

  6. The Hitachi LM032XMBL LCD RS SRAM A14 $4000 R/W E SRAM A15 $8000 DB0-DB7 To write commands use: $8000 To write data use: $C000 To read the Busy flag use: $8000 Jordan Nash - Microprocessor Course

  7. Getting Started Download LCD1.asm from the Lab page. In the file you will find routines to initialize the LCD display, routines that clear the display and routines that print messages. Use them to create an LCD interface of your own and familiarize yourself with them Jordan Nash - Microprocessor Course

  8. Reminder: Some Useful techniques in Assembler Setting flags for initializing your program Tables in Program Memory 16 bit counters The Skip commands for branching Jordan Nash - Microprocessor Course

  9. Assembler III: Main Program CLR r23 SBR r23, $1 Main: ; Do not execute the initialization every time; ; use bit in r23 to flag whether initialization ; has been done SBRC r23, 0 rcallIdisp SBRC r23, 0 CBR r23, $1 ;Clear bit no more init rcallMess1Out rcallBigDel rcall CLRDIS rcall Mess2Out rcallBigDel rcall CLRDIS rjmp Main Jordan Nash - Microprocessor Course

  10. Tables, Messages, ASCII, Bytes Mess1: .db 'C','o','s','t','a','s',' ','F','o','u','d','a','s' Mess1Out: LDI ZH,HIGH(2*Mess1) LDI ZL,LOW(2*Mess1) LDI r18,13 ;there are 13 bytes in the mesage Mess1More: LPM ;copy data from program memory MOV r17, r0 ;move the byte to r17 sts$C000, r17 ;send the byte to the LCD rcallbusylcd ;wait DEC r18 ;check that we have sent all bytes BREQ Mess1End ;if yes quit ADIW ZL, $01 ;point to the next location in PM RJMP Mess1More ;get the next byte Mess1End: ret Jordan Nash - Microprocessor Course

  11. Use 16 bit counters for delays DEL49ms: LDI XH, HIGH(65535) LDI XL, LOW (65535) COUNT3: SBIW XL, 1 BRNE COUNT3 RET Jordan Nash - Microprocessor Course

  12. The Skip assembly commands ; A routine the probes the display BUSY bit ; busylcd: rcallDel49ms ldsr16, $8000 ;read the lcd BUSY bit sbrsr16, 7 ;skip next if busy bit7 is set ret ;return if clear rjmpbusylcd;else loop back You can skip with sbrs,sbrcfor testing registers and with sbis,sbicfor testing I/O Ports Jordan Nash - Microprocessor Course

  13. Basic LCD Commands Commands are written to address $8000 ldi r16,$XX sts$8000,r16 Jordan Nash - Microprocessor Course

  14. Example: clear the display ; This clears the display so we can start all over again ; CLRDIS: ldir16,$01 ; Clear Display send cursor sts$8000,r16 ; to the most left position rcallbusylcd ret In the Hitachi red and white book you will find all of the commands for the LCD display. Jordan Nash - Microprocessor Course

  15. Exercise: A User Interface Start First ? Yes Initialize LCD No The ATmega103 requests input by sending a message to the LCD Send Acknowledge Message to the LCD Read in Input from PORTD or the Keyboard Decode the Input and do something Jordan Nash - Microprocessor Course

More Related