I have LCM1602C LCD which I got with Arduino Starter Kit.I want to Interface it with ATmega16.But no matter what I do LCD just doesn't print anything.Just to check if the LCD is in working condition I connected it to Arduino and uploaded example project and it seems to work just fine.As the code was not working I also tried to run it on Proteus and it ran perfectly just one difference and that is LCM1602C was not available so I used LM016L LCD as both have similar pin configuration. The code I am trying to run on ATmega 16 is as follows:
#include <avr/io.h>
#include <util/delay.h>
#define RS 6
#define E 7
void send_a_command (unsigned char command);
void send_a_character(unsigned char character);
int main(void)
{
_delay_ms(5000);
DDRC = 0xFF;
DDRD = 0xFF;
_delay_ms(50);
send_a_command(0x01);// sending all clear command
send_a_command(0x38);// 16*2 line LCD
send_a_command(0x0F);// screen and cursor blink
send_a_character (0x44);
send_a_character (0x44);
send_a_character (0x44);
send_a_character (0x44);
send_a_character (0x44);
send_a_character (0x44);
send_a_character (0x44);
send_a_character (0x44);
while(1);
}
void send_a_command (unsigned char command)
{
PORTC=command;
PORTD&= ~(1<<RS);
PORTD|= (1<<E);
_delay_ms(50);
PORTD&= ~(1<<E);
PORTC = 0;
}
void send_a_character (unsigned char character)
{
PORTC=character;
PORTD|= (1<<RS);
PORTD|= (1<<E);
_delay_ms(50);
PORTD&= ~(1<<E);
PORTC =0;
}
Image from Proteus simulation:
Note: the initial 5000 ms delay was given because I thought LCD might be missing the starting instructions just after power on.The code doesn't run even after removing that statement.
I tried to search for LCM1602C datasheet but had no luck finding one. So is there some other command instruction set for LCM1602C?