LCD Interface

  • Based on HD44780 LCD controller (Hitachi).
  • Block Diagram
    • E – enable
    • RS – register select
    • R/W – read/write (1 – read, 0 – write)
    • Data – 8 data bits
      • The data bits are bidirectional, but rarely is there a need to read from it.
  • There are two types of information that can be written to the data pins:
    • Data (RS should be set (high)).
    • Command (RS should be cleared (low)).
    • A few useful commands:
      • clear – clears the display.
      • home – move cursor to home (first) position.
      • blink – cursor blinks.
      • auto-increment cursor position.

SDK200 Specifics

  • Data bits are hardwired to PORTA.
  • E hardwired to PORTC pin 7.
  • RS hardwired to PORTC pin 6.
  • WR hardwired to PORTD pin 6 (active low).
  • RD hardwired to PORTD pin 7 (active low).

Writing to the LCD

Command Write Process

  • Clear RS.
  • Clear R/W.
  • Delay 2ms.
  • Set E.
  • Send command to PORTA.
  • Clear E.
  • Delay 2ms.
  • Set RS.
  • Set R/W.
  • Delay 2ms.

Data Write Process

  • Set RS.
  • Clear R/W.
  • Set E.
  • Output data to PORTA.
  • Clear E.
  • Set R/W.
  • Delay 2ms.

Initializing the LCD

Send out sequence of commands:

  • 0x38 – data length = 8, font is 5×7.
  • 0x0f – display on, cursor on, cursor blink.
  • 0x01 – clear display.
  • 0x06 – auto-increment cursor.

Must repeat the command write process for each of these commands.

Example function to write a command to the LCD:

; Writes value in r20 to the LCD as a command
; Assumes ports configured for LCD and RD is set (PORTD, 7 is high)
; Dependencies: delay2ms
lcd_cmd_write:
        ; Set up LCD for accepting a command
        cbi    PORTC, 6     ; RS low --> put in command mode
        cbi    PORTD, 6     ; WR low --> enable write
        sbi    PORTC, 7     ; E high --> enable LCD interface
        out    PORTA, r20   ; write command to data pins
        ; Place LCD back in default configuration
        cbi    PORTC, 7     ; E low --> disable LCD interface
        sbi    PORTC, 6     ; WR high --> disable write
        sbi    PORTD, 6     ; RS high --> put in data mode
        rcall  delay_2ms    ; delay  TODO: must write this function
        ret

You should be able to write functions for:

  • delay_2ms – delay for two milliseconds.
  • lcd_data_write – write value in R20 to the LCD as data.
  • lcd_init – sends a sequence of initialization commands to LCD.
  • lcd_port_init – configures ports used by LCD.
  • lcd_string_write – write the null terminated string stored in program memory (indicated by the Z pointer) to the LCD.
  • lcd_clear – clears the LCD screen.
cs280/lcddisplay.txt · Last modified: 2010/03/09 20:55 (external edit)
 

This website is not owned or managed by the Milwaukee School of Engineering.

© 2003-2010 Dr. Christopher C. Taylor, et. al. • Office: L-343 • Phone: 277-7339 • npǝ˙ǝosɯ@ɹolʎɐʇ • -> RSS <-