motif said:Problem comes when I try it for 4-bit mode.
void init_4_bit_mode()
{
///### initilize as per data-sheet.
lcd_send_nibble(0x30);
lcd_send_nibble(0x30);
lcd_send_nibble(0x30);
//### send initial function set as still LCD is in 8-bit mode.
lcd_send_nibble(0x20);
//### send function set again, 4-bit mode, 2 line LCD , JHD162A
lcd_send_byte(0x28);
//### turnon display, cursor, blink-mode
lcd_send_byte(0x0F);
//### Clear display
lcd_send_byte(0x01);
//### Entry mode, increment, shift=0
lcd_send_byte(0x06);
}
Just checked the datasheet, the initialization procedure includes nibbles for the first bytes.FvM said:Although the lcd_send_nibble() routine is somewhat unusual with it's right shift, the procedure is exactly reproducing the suggested initialization by software in the HD44780 datsheet.
void lcd_send_byte(int8 n)
{
send_nibble(n >> 4);
send_nibble(n & 0xf);
}
void lcd_send_nibble(int8 n)
{
send_nibble(n >> 4);
}
void send_nibble(int8 nibble)
{
output_bit(PIN_A3, ((nibble & 1)));
output_bit(PIN_A4, ((nibble & 2) >> 1));
output_bit(PIN_A5, ((nibble & 4) >> 2));
output_bit(PIN_E0, ((nibble & 8) >> 3));
delay_ms(delay_val);
output_bit(LCD_E, 1);
delay_ms(delay_val);
output_bit(LCD_E, 0);
delay_ms(delay_val);
}
fawadbutt said:i trying to make the program for LCD in 4 bit mode
void lcd_init (void)
{
Delay_ms(50);
LCD_cmd(0x30);
Delay_ms(10);
LCD_cmd(0x30);
Delay_ms(10);
LCD_cmd(0x30);
Delay_ms(10);
LCD_cmd(0x20); //4 bits bus
Delay_ms(10);
LCD_cmd(0x28);
Delay_ms(10);
LCD_cmd(0x08);
Delay_ms(10);
LCD_cmd(0x01);
Delay_ms(10);
LCD_cmd(0x06);
Delay_ms(10);
LCD_cmd(0x0C); //blink off
Delay_ms(50);
}
OK, you didn't specify that. :smile:fawadbutt said:now its work on protues ,,but not work in real circuit
If the exact same circuit and code are running in the exact same board with 8-bit mode, then the possible problems could be:fawadbutt said:if you think no problem in my code
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?