728x90

728x90

Tuesday, January 27, 2026

ATMega644P HD44780 Character LCD Interfacing

Overview

The industrial standard HD44780 character LCD controller is popular display among electronic hobbyists and commercial product for a few decade. Currently it still popular among students who start micro-controller programming, hobbyist electronic project or even low end consumer electronic product. It doesn't obsolete due to the newer replacement controllers that are fully compatible in controller chips and device footprint. It is very easy to use, wide availability and low cost.

ATMega644P HD44780 Character LCD Interfacing

 

There many choices for this LCD, 8x1, 8x2, 16x1, 16x2, 16x4, 20x4 etc. The manufacture produce many types of this LCD that have different character and back-light colors and size. 

The interface of this LCD is an 8-bit parallel port with three control pins. However the micro-processor can interfaces to this LCD using a 8-bit data transfer mode that can save pins usage. It is very common for most of micro-controller programming. For tutorial how to use this LCD controller please visit these post,


ATMega644P LCD Interfacing

This simple task could be done using a smaller micro-controller for instance the PIC16F84A. However we can use any micro-controller that is suitable for the project. I have many 16x2 LCD and a few 16x4 LCD that left from my university time and finished projects.

TC1604A-01A 16x4 LCD Interfacing

This LCD module is obsolete now. But there are a lot of replacement LCD module with different color and very low cost. In this example the ATMega644P use its 8-bit PortA to send command and data to the LCD while PortC is selected as control pins. The R/W pin is wire to GND because the micro-controller just need to send data or command.

ATMega644P HD44780 Character LCD Interfacing
Top View

 

ATMega644P HD44780 Character LCD Interfacing
Back View

The brightness of this LCD is lower than new product since there is a limit on LED technology at that time. 

  1. /*
  2. * 6-hd4470_1604_8.c
  3. *
  4. * Created: 1/27/2026 8:02:41 PM
  5. * Author : Admin
  6. */

  7. #include <avr/io.h>
  8. #include <util/delay.h>
  9. #define F_CPU 16000000UL

  10. #define RS 0
  11. #define EN 2

  12. void lcd_command(uint8_t command){
  13. PORTA&=~(1<<RS);
  14. PORTA|=(1<<EN);
  15. PORTC=command;
  16. PORTA&=~(1<<EN);
  17. _delay_us(100);
  18. }

  19. void lcd_data(uint8_t data){
  20. PORTA|=(1<<RS);
  21. PORTA|=(1<<EN);
  22. PORTC=data;
  23. PORTA&=~(1<<EN);
  24. _delay_us(100);
  25. }

  26. void lcd_text(char *txt){
  27. while(*txt) lcd_data(*txt++);
  28. }

  29. void lcd_xy(char x, char y){
  30. // 20x4 LCD
  31. //uint8_t tbe[]={0x80,0xC0,0x94,0xD4};
  32. // 16x4 LCD
  33. char tbe[]={0x80,0xC0,0x90,0xD0};
  34. lcd_command(tbe[y-1]+x-1);
  35. _delay_ms(100);
  36. }

  37. void lcd_clear(void){
  38. lcd_command(0x01);
  39. _delay_ms(1000);
  40. }
  41. void lcd_init(void){
  42. DDRA=0xFF;
  43. DDRC=0xFF;
  44. lcd_command(0x38);
  45. _delay_us(100);
  46. lcd_command(0x38);
  47. _delay_us(100);
  48. lcd_command(0x0C);
  49. _delay_us(100);
  50. lcd_command(0x06);
  51. _delay_us(100);
  52. }

  53. struct date_time{
  54. char hour;
  55. char minute;
  56. char second;
  57. char *day_w;
  58. char day_m;
  59. char month;
  60. int year;
  61. };
  62. int main(void)
  63. {
  64. /* Replace with your application code */
  65. lcd_init();
  66. lcd_clear();
  67. lcd_text("HELLO WORLD!");
  68. lcd_xy(1,2);
  69. lcd_text("ATMEGA644P-20PU");
  70. lcd_xy(1,3);
  71. lcd_text("TC1604A-01A 16x4");
  72. lcd_xy(1,4);
  73. lcd_text("Microchip Studio");
  74. _delay_ms(5000);
  75. lcd_clear();
  76. struct date_time my_date={10,30,10,
  77. "Wed",28,1,2026};
  78. char date[16];
  79. lcd_xy(1,1);
  80. lcd_text("Date:");
  81. sprintf(date,"%s %02d/%02d/%04d",
  82. my_date.day_w,my_date.day_m,
  83. my_date.month,my_date.year);
  84. lcd_xy(1,2);
  85. lcd_text(date);
  86. lcd_xy(1,3);
  87. lcd_text("Time:");
  88. sprintf(date,"%02d:%02d:%02d",
  89. my_date.hour,my_date.minute,
  90. my_date.second);
  91. lcd_xy(1,4);
  92. lcd_text(date);
  93. while (1)
  94. {
  95. }
  96. }


Proteus VSM also has a model for this old LCD module.

ATMega644P HD44780 Character LCD Interfacing
Schematic and Simulation

I wire the example program on my AVR Prototype Board with additional wiring on bread since this LCD is not on my AVR Prototype Board.

ATMega644P HD44780 Character LCD Interfacing

 

ATMega644P HD44780 Character LCD Interfacing 

I have been using PCBWay for many years now. PCBWay fabricate PCBs at low cost, fast processing time for only 24 hours, and fast delivery time using any carrier options. This double side 10cmx10cm can be fabricate at only 5USD for 5 to 10pcs by PCBWay. It's a standard PCB with silk screen and solder mask.

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
10 PCBs for only 5USD
 

For different size of PCB we can instantly quote on PCBWay website using a zip PCB Gerber file without account.

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
PCBWay Instant Quote

ATMega644P 1602A 16x2 LCD Interfacing

I place a 16x2 LCD on my  AVR Prototype Board. I use a 4-bit data transfer mode to save pin counts. The ATMega644P and the 1602A are wired as follow:

  • LCD RS(Register Select) connects to PC2.
  • LCD RW(Read/Write) connects to GND.
  • LCD EN(Enable) connects to PC3.
  • LCD D7:4 connects to PC7:4 (4-bit data bus). 

Source Code:

  1. /*
  2. * 6-hd44780_1602_4.c
  3. *
  4. * Created: 1/27/2026 10:25:31 PM
  5. * Author : Admin
  6. */

  7. #include <avr/io.h>
  8. #include <stdio.h>
  9. #include <util/delay.h>
  10. #define F_CPU 16000000UL

  11. #define RS 2
  12. #define EN 3

  13. const char d_time=50;

  14. void lcd_command(char command){
  15. char temp;
  16. temp=command&0xF0;
  17. PORTC=temp|(1<<EN);
  18. _delay_us(d_time);
  19. PORTC=temp;
  20. _delay_us(d_time);
  21. temp=command<<4;
  22. PORTC=temp|(1<<EN);
  23. _delay_us(d_time);
  24. PORTC=temp;
  25. _delay_us(d_time);
  26. }

  27. void lcd_data(char data){
  28. char temp;
  29. temp=data&0xF0;
  30. PORTC=temp|(1<<EN)|(1<<RS);
  31. _delay_us(d_time);
  32. PORTC=temp|(1<<RS);
  33. _delay_us(d_time);
  34. temp=data<<4;
  35. PORTC=temp|(1<<EN)|(1<<RS);
  36. _delay_us(d_time);
  37. PORTC=temp|(1<<RS);
  38. _delay_us(d_time);
  39. }
  40. void lcd_init(void){
  41. DDRC=0xFF;
  42. lcd_command(0x33);
  43. _delay_us(100);
  44. lcd_command(0x32);
  45. _delay_us(100);
  46. lcd_command(0x28);
  47. _delay_us(100);
  48. lcd_command(0x0F);
  49. _delay_us(100);
  50. lcd_command(0x01);
  51. _delay_ms(5);
  52. lcd_command(0x06);
  53. _delay_us(100);
  54. }
  55. void lcd_xy(char x, char y){
  56. char addr[]={0x80,0xC0};
  57. lcd_command(addr[y-1]+x-1);
  58. }
  59. void lcd_text(char *text){
  60. while(*text) lcd_data(*text++);
  61. }
  62. void lcd_clear(void){
  63. lcd_command(0x01);
  64. _delay_ms(5);
  65. }

  66. int main(void)
  67. {
  68. /* Replace with your application code */
  69. lcd_init();
  70. lcd_text("ATMega644P-20PU");
  71. lcd_xy(1,2);
  72. lcd_text("Microchip Studio");
  73. _delay_ms(10000);
  74. lcd_clear();
  75. lcd_command(0x0C);
  76. DDRA=0x00;
  77. PINA=0xFF;
  78. char data=0,data_old,temp[16];
  79. while (1)
  80. {
  81. data=PINA;
  82. if(data!=data_old){
  83. lcd_xy(1,1);
  84. sprintf(temp,"HEX: 0x%02X D: %3d",data,data);
  85. lcd_text(temp);
  86. for(char i=0;i<sizeof(temp);i++) temp[i]=0;
  87. for (char i=0;i<8;i++)
  88. {
  89. if(data&(1<<i)) temp[7-i]='1';
  90. else temp[7-i]='0';
  91. }
  92. lcd_xy(1,2); lcd_text("BIN: "); lcd_text(temp);
  93. }
  94. data_old=data;
  95. }
  96. }


Schematic and Simulation:

ATMega644P HD44780 Character LCD Interfacing

ATMega644P HD44780 Character LCD Interfacing


I tested this demo example on my AVR Prototype Board.

ATMega644P HD44780 Character LCD Interfacing
I tested this demo example on my AVR Prototype Board.

ATMega644P HD44780 Character LCD Interfacing
I tested this demo example on my AVR Prototype Board.

ATMega644P HD44780 Character LCD Interfacing
I tested this demo example on my AVR Prototype Board.



No comments:

Post a Comment

320x50

Search This Blog

tyro-728x90