Introduction
The HD44780 character LCD controller still popular among micro-controller programmer today even in small electronic control projects. Currently there are a lot of Chinese equivalent LCD controller that is very low cost and low power.
![]() |
| MikroC LCD Example |
It has 8-bit data bus with three control signal - Register Select (RS), Read or Write (R/W) and Enable (E). However it operate is a single 8-bit data transfer mode or 4-bit (two times) data transfer mode. Using its 4-bit data transfer mode is very common today. The 8-bit data is divided into two nibbles, higher nibble is transferred first and then the lower nibble.
![]() |
| A 16x4 HD44780 Character LCD |
MikroC Programming for HD44780 and dsPIC30F2010
MikroC for dsPIC has an LCD driver for HD44780 that operates in 4-bit data transfer mode with select-able control pins and data pins (D4:D7). The R/W pin must wires to GND as the master MCU only need to send commands or data.
![]() |
| MikroC LCD Example |
It does not need a schematic as we can read and understand the C source codes.
![]() |
| Schematic Diagram |
I don't need to write my codes due to time constraint. I use the MikroC LCD example in its library manual. There are some major routines in MikroC:
Library Routines
MikroC Source Code:
- // LCD module connections
- sbit LCD_RS at LATE0_bit;
- sbit LCD_EN at LATE1_bit;
- sbit LCD_D4 at LATE2_bit;
- sbit LCD_D5 at LATE3_bit;
- sbit LCD_D6 at LATE4_bit;
- sbit LCD_D7 at LATE5_bit;
- sbit LCD_RS_Direction at TRISE0_bit;
- sbit LCD_EN_Direction at TRISE1_bit;
- sbit LCD_D4_Direction at TRISE2_bit;
- sbit LCD_D5_Direction at TRISE3_bit;
- sbit LCD_D6_Direction at TRISE4_bit;
- sbit LCD_D7_Direction at TRISE5_bit;
- // End LCD module connections
- char txt1[] = "mikroElektronika";
- char txt2[] = "EasydsPIC4A";
- char txt3[] = "Lcd4bit";
- char txt4[] = "example";
- char i; // Loop variable
- void Move_Delay() { // Function used for text moving
- Delay_ms(500); // You can change the moving speed here
- }
- void main(){
- ADPCFG = 0xFFFF; // Configure AN pins as digital I/O
- Lcd_Init(); // Initialize LCD
- Lcd_Cmd(_LCD_CLEAR); // Clear display
- Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
- Lcd_Out(1,6,txt3); // Write text in first row
- Lcd_Out(2,6,txt4); // Write text in second row
- Delay_ms(2000);
- Lcd_Cmd(_LCD_CLEAR); // Clear display
- Lcd_Out(1,1,txt1); // Write text in first row
- Lcd_Out(2,5,txt2); // Write text in second row
- Delay_ms(2000);
- // Moving text
- for(i=0; i<4; i++) { // Move text to the right 4 times
- Lcd_Cmd(_LCD_SHIFT_RIGHT);
- Move_Delay();
- }
- while(1) { // Endless loop
- for(i=0; i<8; i++) { // Move text to the left 7 times
- Lcd_Cmd(_LCD_SHIFT_LEFT);
- Move_Delay();
- }
- for(i=0; i<8; i++) { // Move text to the right 7 times
- Lcd_Cmd(_LCD_SHIFT_RIGHT);
- Move_Delay();
- }
- }
- }




No comments:
Post a Comment