Karthick000
Newbie level 4
I am interfacing JHD162a LCD with LPC1768. Problem I am facing is getting the rectangular black block in the 1st row and i am trying to print "hello world"
the character is not displaying. here is my code. I checked the hardware connection and supply everything is proper. Could any one explain what is the issue.
Hardware connection
LCD pin
the character is not displaying. here is my code. I checked the hardware connection and supply everything is proper. Could any one explain what is the issue.
Hardware connection
LCD pin
- Pin 1 - Ground
- Pin 2 - 5v
- pin 3 - (0 to 3.3V) pot kept maimum volt
- Pin 4 - RS - connected to port 2 pin 0
- Pin 5 - RW - Ground (only write operation)
- Pin 6 - EN - connected to port 2 pin 1
- Pin 7 - Data line - Connected to port 0 pin0
- Pin 8 - Data line - Connected to port 0 pin1
- Pin 9 - Data line - Connected to port 0 pin2
- Pin 10 - Data line - Connected to port 0 pin3
- Pin 11,12,13,14 - Ground
- Pin 15 - to resisor 200ohm to 5 supply
- Pin 16 - Ground
Code:
#define BIT(x) (1 << x)
#define BIT_LCD_DATA_CON_REG_SEL BIT(0)
#define BIT_LCD_EN_DIS_LATCH BIT(1)
#define LCD_CMD_DATA_MASK 0x0F
int main()
{
uint32_t N_timer;
SystemClockUpdate();
WDTInit();
LPC_GPIO2 -> FIODIR0 = 0xFF;//direction register
LPC_GPIO2 -> FIOCLR0 = 0xFF;//Clear Port value
for (N_timer = 0; N_timer < 2; N_timer++)
{
init_timer (N_timer, TIME_INTERVAL);
enable_timer (N_timer);
}
JHD_LCD_Init ();
JHD_send_LCD_data ();
while(1);
}
void JHD_LCD_latch ( void )
{
LPC_GPIO2 -> FIOSET0 |= BIT_LCD_EN_DIS_LATCH;
delayMs(0,20);
LPC_GPIO2 -> FIOCLR0 |= BIT_LCD_EN_DIS_LATCH;
delayMs(0,20);
}
void JHD_LCD_Init( void )
{
JHD_LCD_Inst ();
send_lcd_cmd(0x2C, 0);
send_lcd_cmd(0x0F, 0);
send_lcd_cmd(0x10, 0);
send_lcd_cmd(0x07, 0);
send_lcd_cmd(0x01, 0);
send_lcd_cmd(0x80, 0);
}
uint8_t JHD_send_LCD_data ()
{
char *data_string = "hello world";
uint8_t index = 0;
while(data_string [index] != '\0')
{
send_lcd_data((unsigned char)data_string [index], 1);
index++;
}
return 0;
}
void JHD_LCD_Inst( void )
{
delayMs(0,100);
/*Port 0 lower nibble will act as DATA line*/
LPC_GPIO0 -> FIODIRL = 0x000F; /*o/p line*/
LPC_GPIO0 -> FIOCLRL = 0x000F;
/*Port 2 bit 0(RS),1(EN) will act as cmd line and initialized in main function*/
}
void JHD_LCD_data_config( void )
{
LPC_GPIO0 -> FIOCLRL = 0x000F;
LPC_GPIO0 -> FIOSETL = 0x0000;
LPC_GPIO2 -> FIOSET0 |= (0x000F & BIT_LCD_DATA_CON_REG_SEL);
delayMs(0,20);
JHD_LCD_latch ();
}
void send_lcd_cmd (unsigned char cmd, uint8_t rs_value)
{
WDTFeed();
LPC_GPIO0 -> FIOCLRL = 0x000F;
LPC_GPIO0 -> FIOSETL = (0x000F & (uint16_t)((cmd >> 4) & LCD_CMD_DATA_MASK));
LPC_GPIO2 -> FIOSET0 |= (0x000F & rs_value);
JHD_LCD_latch ();
LPC_GPIO0 -> FIOCLRL = 0x000F;
LPC_GPIO0 -> FIOSETL = (0x000F & (uint16_t)(cmd & LCD_CMD_DATA_MASK));
LPC_GPIO2 -> FIOSET0 |= (0x000F & rs_value);
JHD_LCD_latch ();
}
void send_lcd_data (unsigned char data, uint8_t rs_value)
{
WDTFeed();
LPC_GPIO0 -> FIOCLRL = 0x000F;
LPC_GPIO0 -> FIOSETL = (0x000F & (uint16_t)((data >> 4) & LCD_CMD_DATA_MASK));
LPC_GPIO2 -> FIOSET0 |= (0x000F & rs_value);
JHD_LCD_latch ();
LPC_GPIO0 -> FIOCLRL = 0x000F;
LPC_GPIO0 -> FIOSETL = (0x000F & (uint16_t)(data & LCD_CMD_DATA_MASK));
JHD_LCD_latch ();
}