I've got an LCD, connected to an Atmega32, working with single characters using this function:
void send_char(uint8_t c){
PORTD = c; // set the output pins to the ascii value of the char
PORTB |= 0x05;
_delay_us(1);
PORTB &= 0xfa;
_delay_us(60);
PORTD = 0x00;
update_cursor();
}
I can call this with a character as an argument: send_char('a');
and it works.
Then I tried wrapping a send_string function around it:
void send_string(const char * msg){
while (*msg != '\0'){
send_char(*msg++);
}
}
This just puts gibberish on my LCD indicating that the ASCII value has been far off. And when I try passing an empty string (send_string("")
) a minimum of three gibberish characters get displayed on the LCD.