I'm trying to implement a function that displays the letter `c` on the LCD using 4-bit mode. But when I run the code on Proteus I get a blank lcd.
I tried the code with 8 bit mode (without the bits manipulation) and works perfectly. So there's nothing wrong with lcd_send() and lcd_save() i guess.
I know there's tons of libraries for that, but i'm trying to write it for learning purpose.
Here's my code:
I will attach the code with proteus file in case you needed it.
If there's any information needed, please tell me. Thanks.
I tried the code with 8 bit mode (without the bits manipulation) and works perfectly. So there's nothing wrong with lcd_send() and lcd_save() i guess.
I know there's tons of libraries for that, but i'm trying to write it for learning purpose.
Here's my code:
Code:
void init_lcd()
{
//Setting DDRA and DDRC to output
struct conf con;
con.port_pointer = PINA_ADDR;
con.value= 0xff;
set_direction_port(con);
con.port_pointer = PINC_ADDR;
con.value= 0xff;
set_direction_port(con);
lcd_send_cmd(0x28);
lcd_send_cmd(0x0c);
}
void lcd_send_char(char c)
{
// Sets direction to write
set_lcd_dir(0);
// Enables data register
set_control_reg(1);
lcd_send(c & 0xf0);
lcd_save();
set_lcd_dir(0);
set_control_reg(1);
lcd_send((c & 0x0f) << 4);
lcd_save();
}
void lcd_send(char c)
{
struct conf con;
con.port_pointer = PINC_ADDR;
con.value= c;
write_port(con);
}
void lcd_save()
{
//Saving
set_lcd_enable(0);
_delay_ms(1);
set_lcd_enable(1);
_delay_ms(1);
set_lcd_enable(0);
}
If there's any information needed, please tell me. Thanks.
Attachments
-
55.5 KB Views: 4
Last edited: