Hallo! Ich habe hier einen Atmega 32 und ein Displaytech162 (Controller HD44780) LCD Display im 4-Bit Modus. Das übertragen von einzelnen Zeichen funktioniert soweit mal. Jetzt will ich überprüfen ob auch das richtige Zeichen am Display angezeigt wird. Dazu will ich mit folgender Funktion das Display auslesen:
1 | /** |
2 | * This function read the data from LCD controller |
3 | * Input: rs 1: read data |
4 | * 0: read busy flag / address counter |
5 | * Returns: byte read from LCD controller |
6 | */ |
7 | |
8 | uint8_t lcd_read(uint8_t rs) { |
9 | uint8_t data; |
10 | |
11 | if (rs) |
12 | lcd_rs_high(); /* RS=1: read data */ |
13 | else |
14 | lcd_rs_low(); /* RS=0: read busy flag */ |
15 | |
16 | lcd_rw_high(); /* RW=1 read mode */ |
17 | |
18 | LCD_DDR_DB &= ~(0x0F << LCD_DB); /* configure data pins as input */ |
19 | |
20 | lcd_en_high(); |
21 | _delay_us(LCD_ENABLE_US); |
22 | data = LCD_PORT_DB << 4; /* read high nibble first */ |
23 | lcd_en_low(); |
24 | |
25 | _delay_us(LCD_ENABLE_US); /* Enable 500ns low */ |
26 | |
27 | lcd_en_high(); |
28 | _delay_us(LCD_ENABLE_US); |
29 | data |= LCD_PORT_DB & 0x0F; /* read low nibble */ |
30 | lcd_en_low(); |
31 | |
32 | //initialize to the preconfiguration |
33 | LCD_DDR_DB |= (0x0F << LCD_DB); /* configure data pins as output */ |
34 | lcd_rs_low(); |
35 | lcd_rw_low(); |
36 | |
37 | return data; |
38 | } |
Leider kommt beim high nibble auch immer der Wert vom low nibble zurück. Also wenn ich ein 'L' auslesen möchte dann kommt nicht 0x4C zurück sondern 0xCC. Weiß jemand warum das so ist? godi