Hi liebe Forengemeinde,
ich habe eine LCD des Typs Data Vision DV-16244 an meinen AVR AtMega328p
angeschlossen und versuche jetzt, auf diesem Buchstaben und/oder Strings
auszugeben.
Initialisierung und so weiter klappt auch alles super, nur will die LCD
einfach keine Buchstaben anzeigen. Der Cursor bewegt sich beim
Anschalten sogar eine Stelle weiter nach rechts, aber es wird kein
Buchstabe angezeigt.
Ich habe den Controller ähnlich wie im AVR-GCC-Tutorial programmiert:
1 | #include <avr/io.h>
|
2 | #include <util/delay.h>
|
3 |
|
4 | #define CONTROL PORTD //LD, HD
|
5 | #define MODES PORTB //RS, RW, ENABLE
|
6 | #define ENABLE 3
|
7 | #define RW 2
|
8 | #define RS 0
|
9 |
|
10 |
|
11 | void enableExecuting(void)
|
12 | {
|
13 | MODES |= 1<<ENABLE;
|
14 | _delay_us(20);
|
15 | MODES &= ~(1<<ENABLE);
|
16 | }
|
17 |
|
18 | void sendData(uint8_t data)
|
19 | {
|
20 | data &= 0xF0;
|
21 |
|
22 | CONTROL &= ~(0xF0 >> (4-PD4));
|
23 | CONTROL |= (data >> (4-PD4));
|
24 | enableExecuting();
|
25 | }
|
26 |
|
27 | void sendCmd(uint8_t command)
|
28 | {
|
29 | MODES &= ~(1<<RS);
|
30 | sendData(command);
|
31 | sendData(command<<4);
|
32 | _delay_us(46);
|
33 | }
|
34 |
|
35 | void sendChar(uint8_t character)
|
36 | {
|
37 | MODES |= 1<<RS;
|
38 | sendData(character);
|
39 | enableExecuting();
|
40 | sendData(character<<4);
|
41 | enableExecuting();
|
42 | }
|
43 |
|
44 | void initLCD(void)
|
45 | {
|
46 | DDRB |= (1<<RS)|(1<<ENABLE);
|
47 | DDRD |= 0xF0<<CONTROL;
|
48 | CONTROL = 0;
|
49 | MODES &= ~((1<<RS)|(1<<ENABLE));
|
50 |
|
51 | _delay_ms(15);
|
52 |
|
53 | sendCmd(0x30);
|
54 | _delay_ms(5);
|
55 | enableExecuting();
|
56 | _delay_ms(1);
|
57 | enableExecuting();
|
58 | _delay_ms(1);
|
59 |
|
60 | sendCmd(0x20 | 0x00); //function -> 4-bit
|
61 | _delay_ms(5);
|
62 |
|
63 | sendCmd(0x08 | 0x04 | 0x02 | 0x01);
|
64 |
|
65 | sendCmd(0x01); //clear display
|
66 | _delay_ms(2);
|
67 | }
|
68 |
|
69 |
|
70 | int main(void)
|
71 | {
|
72 | initLCD();
|
73 | sendChar('A');
|
74 | while(1)
|
75 | ;
|
76 |
|
77 | return 0;
|
78 | }
|
Danke schon im Voraus für eure Antwrten! :)
kwest