Hi:
I am trying to print few words on an 8 bits 2x16 LCD with Hitachi controller,
but I am not able to print anything, I just see a thin line blinking few times. I am using PIC18, but the pic choice does not matter since this is my first LCD code, and I think it must be code problem, and I would guess it must be in the init method, because I am not very sure about it.
Here is the code:
#define LCD_EN 1 // Port A bit 0 ( Enables LCD )
#define LCD_WR 2 // Port A bit 1 ( Logic 0 = Write )
#define LCD_RS 4 // Port A bit 2 ( Register select 1=Data transfer)
// PortD is D0-D7
void lcd_clear(void)
{
setInstructionBit_Lo(LCD_RS);
PORTA &= 0xf0;
//PORTD = 0x01;
lcd_write(0x01);
delay(4000);
setInstructionBit_Hi(LCD_RS);
}
void LCD_Toggle_EN(void)
{
setInstructionBit_Hi(LCD_EN);
delay(4000);
setInstructionBit_Lo(LCD_EN);
delay(4000);
}
void LCD_init(void)
{
delay (8000); //30ms Power ON delay
setInstructionBit_Lo(LCD_RS);
lcd_write(0x0c); // // Display is ON
lcd_write(0x0e); // cursor active and no blink
//lcd_write(0x0f); // cursor active and blink
LCD_Toggle_EN();
lcd_write(1); // clear display
LCD_Toggle_EN();
lcd_write(0x38); // 8 bit data mode 2 line ( 5x7 font )
LCD_Toggle_EN();
setInstructionBit_Hi(LCD_RS);
}
void main (void)
{
TRISD = 0;
TRISA = 0;
PORTA = 0x00;
PORTD = 0x00;
LCD_init();
while (1)
{
lcd_clear();
lcd_write('T');
lcd_write('e');
lcd_write('s');
lcd_write('t');
lcd_write('!');
}
}
PS: This LCD has 16 pins, and supposedly has a LED backlight, I am not sure how to turn this LED ON, I tried to connect pin15 to GND, and pin16 to +5V, but it did not work.
If you could help, please do.
Thanks a lot folks.
I am trying to print few words on an 8 bits 2x16 LCD with Hitachi controller,
but I am not able to print anything, I just see a thin line blinking few times. I am using PIC18, but the pic choice does not matter since this is my first LCD code, and I think it must be code problem, and I would guess it must be in the init method, because I am not very sure about it.
Here is the code:
#define LCD_EN 1 // Port A bit 0 ( Enables LCD )
#define LCD_WR 2 // Port A bit 1 ( Logic 0 = Write )
#define LCD_RS 4 // Port A bit 2 ( Register select 1=Data transfer)
// PortD is D0-D7
void lcd_clear(void)
{
setInstructionBit_Lo(LCD_RS);
PORTA &= 0xf0;
//PORTD = 0x01;
lcd_write(0x01);
delay(4000);
setInstructionBit_Hi(LCD_RS);
}
void LCD_Toggle_EN(void)
{
setInstructionBit_Hi(LCD_EN);
delay(4000);
setInstructionBit_Lo(LCD_EN);
delay(4000);
}
void LCD_init(void)
{
delay (8000); //30ms Power ON delay
setInstructionBit_Lo(LCD_RS);
lcd_write(0x0c); // // Display is ON
lcd_write(0x0e); // cursor active and no blink
//lcd_write(0x0f); // cursor active and blink
LCD_Toggle_EN();
lcd_write(1); // clear display
LCD_Toggle_EN();
lcd_write(0x38); // 8 bit data mode 2 line ( 5x7 font )
LCD_Toggle_EN();
setInstructionBit_Hi(LCD_RS);
}
void main (void)
{
TRISD = 0;
TRISA = 0;
PORTA = 0x00;
PORTD = 0x00;
LCD_init();
while (1)
{
lcd_clear();
lcd_write('T');
lcd_write('e');
lcd_write('s');
lcd_write('t');
lcd_write('!');
}
}
PS: This LCD has 16 pins, and supposedly has a LED backlight, I am not sure how to turn this LED ON, I tried to connect pin15 to GND, and pin16 to +5V, but it did not work.
If you could help, please do.
Thanks a lot folks.