-
-
HD44780 Initialisierungsproblem mit Atmega32
Moin,
als ich mir eine eigene HD44870 Bibliothek schreiben wollte, bin ich wohl auf eine Tretmine getreten.
Mein Aufbau
uC: Atmega32L-8PU, bei 8MHz
Verkabelung:
PORTA (PA0...PA7) -> DB0...DB7
RS -> PC0
R/W -> PC1
E -> PC2
DDR Flags alle korrekt gesetzt.
Irgendwie scheint mein Code den Controller nicht zu initalisieren, ich habe die Delays extra hoch gewaehlt um nicht in eine Falle zu treten - findet hier jemand meinen Fehler?
[php:1:7facd1837d]
#include "lcd.h"
#include <avr/io.h>
#include <util/delay.h>
#define F_CPU 8000000UL
void lcd_epulse() {
PORTC = (1 << PC2);
_delay_us(2);
PORTC = (0 << PC2);
_delay_ms(100); /* give the controller a rest, for debugging */
}
void lcd_command(char cmd) {
/* RW and RS = 0 */
PORTC = (0 << PC1) | (0 << PC0);
/* and move out */
PORTA = cmd;
}
void lcd_init() {
/* initalize RS, RW and E */
PORTC = (0 << PC2) | (0 << PC1) | (0 << PC0);
/* wait 15ms for firing up vcc */
_delay_ms(15);
/* Set 8-bit mode 3 times like proposed in the HD44870 datasheet */
PORTA = (0 << PA7) | (0 << PA6) | (1 << PA5) | (1 << PA4) | (0 << PA3) | (0 << PA2) | (0 << PA1) | (0 << PA0);
lcd_epulse();
_delay_ms(4);
lcd_epulse();
_delay_us(100);
lcd_epulse();
_delay_us(100);
/* set runtime mode */
PORTA = (0 << PA7) | (0 << PA6) | (1 << PA5) | (1 << PA4) | (1 << PA3) | (1 << PA2) | (0 << PA1) | (0 << PA0);
lcd_epulse();
_delay_us(100);
/* now we can use standard lcd commands to control it */
lcd_command(0x0
; /* lcd off */
lcd_command(0x01); /* lcd clear */
lcd_command(0x07); /* set lcd entry mode */
}
[/php:1:7facd1837d]
Wenn das Datenblatt nicht luegt, sollte ja 'lcd clear' das Display loeschen, sehen tu ich aber noch davon nichts (nur die Standard Kontrastbalken).
Berechtigungen
- Neue Themen erstellen: Nein
- Themen beantworten: Nein
- Anhänge hochladen: Nein
- Beiträge bearbeiten: Nein
-
Foren-Regeln
Lesezeichen