Ich versuche gerade ein 44780 kompatibles LCD 2x16 im 4-bit Modus über ein ATmega8 anzusteuern. Die Datenbits am LCD (D4-D7) sind am PORTD.4 - PORTD.7 des μC und die Kontrollpins E, RW und RS ebenfalls auf die noch freien Pins am PORTD verbunden. Die Aufteilung eines Byte in High und Low Nibble in C ist kein Problem. Die Frage ist aber, wie übermittle ich ein Byte bzw. diese Nibbles? Pseudocode genügt.
Ich habe auf mal wieder ein LCD am Atmega8 etwas gefunden und taugt der folgende Ablauf? Falls ja, werde ich diesen Assembler Code in C umschreiben.
Wenn der Ablauf klar ist, werde ich mich an die Initialisierung machen!
Ich habe auf mal wieder ein LCD am Atmega8 etwas gefunden und taugt der folgende Ablauf? Falls ja, werde ich diesen Assembler Code in C umschreiben.
LCD_init:
;**** for the most LCD you must write 3times a dummy command before you change to 4Bit***
ldi temp, 0b00001110 ;control lines are output, rest is input
out DDRD, temp
rcall LCD_delay ;first, we'll tell the LCD that we want to use it
ldi arg, 0x20 ;in 4-bit mode.
rcall LCD_command8 ;LCD is still in 8-BIT MODE while writing this command!!!
rcall LCD_delay
ldi arg, 0x20 ;NOW: 2 lines, 5*7 font, 4-BIT MODE! ** DUMMY ***
rcall LCD_command ;
rcall LCD_wait
ldi arg, 0x20 ;NOW: 2 lines, 5*7 font, 4-BIT MODE! ** DUMMY ***
rcall LCD_command ;
rcall LCD_wait
ldi arg, 0x28 ;NOW: 2 lines, 5*7 font, 4-BIT MODE! ** this change to 4bit 2 lines **
rcall LCD_command ;after this point you don't can change anything 'show HD44780 Datasheet'
Wenn der Ablauf klar ist, werde ich mich an die Initialisierung machen!