hello,
I have the following LCD code which works where the ATmega32 PD4 to PD7 pins are connected to LCD D4 to D7 pins.
the connection is as shown,
I wanted to change the code to work with ATmega328p pins PC0 to PC3 connected to D4 to D7 as shown below.
what changes do I have to make in the above code? I changed to PORTC = (PORTC & 0x0F) | (cmd & 0xF0); to PORTC = (PORTC & 0xF0) | (cmd & 0xF0); but this does not work.
I have the following LCD code which works where the ATmega32 PD4 to PD7 pins are connected to LCD D4 to D7 pins.
Code:
void lcdcmd(unsigned char cmd){
PORTC = (PORTC & 0x0F) | (cmd & 0xF0); // send high nibble
PORTB &= ~RS; //send 0 to select command register
PORTB |= E; //send high
_delay_ms(5); //wait
PORTB &= ~E; //send low
_delay_ms(5); //wait
PORTC = (PORTC & 0x0F) | (cmd<<4); //send low nibble
PORTB |= E; //send high
_delay_ms(5); //wait
PORTB &= ~E; //send low
_delay_ms(5); //wait
}
I wanted to change the code to work with ATmega328p pins PC0 to PC3 connected to D4 to D7 as shown below.
what changes do I have to make in the above code? I changed to PORTC = (PORTC & 0x0F) | (cmd & 0xF0); to PORTC = (PORTC & 0xF0) | (cmd & 0xF0); but this does not work.