Saturday, March 15, 2008

ATMega8 driving HD44780 LCD

AVRLibLCD.jpgBaby steps here folks. I've just got my Atmel ATMega8 to drive an HD44780 LCD using the 4 bit parallel interface. (Previously I've been using a serial interface which is much simpler).

All the heavy lifting is done by AVRlib, a great library with lots of helpful libraries for driving external hardware.

Beware, there is a very similarly named library AVR-Libc, which also looks good.

I'm driving the LCD in "Port interface" mode and using the 4 bit data mode. As speed isn't important for my application I've chosen to save the extra 4 dataport pins.

Here's my config from lcdconf.h:


#define LCD_PORT_INTERFACE

// Enter the parameters for your chosen interface'
// if you chose the LCD_PORT_INTERFACE:
#ifdef LCD_PORT_INTERFACE
#ifndef LCD_CTRL_PORT
// port and pins you will use for control lines
#define LCD_CTRL_PORT PORTD
#define LCD_CTRL_DDR DDRD
#define LCD_CTRL_RS 2
#define LCD_CTRL_RW 3
#define LCD_CTRL_E 4
#endif
#ifndef LCD_DATA_POUT
// port you will use for data lines
#define LCD_DATA_POUT PORTD
#define LCD_DATA_PIN PIND
#define LCD_DATA_DDR DDRD
// access mode you will use (default is 8bit unless 4bit is selected)
#define LCD_DATA_4BIT
#endif
#endif


My wiring for the pins on the LCD circuit board is as follows:


  1. Vss 0V

  2. Vdd 5V

  3. Contrast Pot 10K wiper

  4. RS - C2

  5. R/W - C3

  6. Enable - C4

  7. D0 No Connection

  8. D1 No Connection

  9. D2 No Connection

  10. D3 No Connection

  11. D4 - D4

  12. D5 - D5

  13. D6 - D6

  14. D7 - D7

  15. No Connection

  16. No Connection



Many thanks Pascal Stang!

1 comment:

Anonymous said...

hi everybody,
i m beginner in avr section well i m trying to interface atmega8535 with hd44780 please help me with very basic example for that my email tarunkanda2000@yahoo.com thanks for ur blog sharing these sort of things.