Wie sieht das aus, sollte man bei der I2C Verbindung (100kbits) nach
jedem geänderten Bit das Byte an den PCF5854 senden? Oder reicht es so
wie folgt?
LCD_PORT ist hier kein avr Port sondern lediglich ein Byte, welches aber
von Hand über I2C geschoben werden.
Hier ein kurzer Einblick.
1 | static void lcd_enable(void)
|
2 | {
|
3 | LCD_PORT |= (1 << LCD_EN);
|
4 | lcd_sendOut(LCD_PORT);
|
5 | delay_us(LCD_DELAY_ENABLE_PULSE);
|
6 | LCD_PORT &= ~(1 << LCD_EN);
|
7 | lcd_sendOut(LCD_PORT);
|
8 | }
|
9 |
|
10 | static void lcd_write(unsigned char data, unsigned char rs)
|
11 | {
|
12 | if (rs) LCD_PORT |= (1 << LCD_RS); // Schreibe Daten
|
13 | else LCD_PORT &= ~(1 << LCD_RS); // Schreibe Befehl
|
14 | LCD_PORT &= ~(1 << LCD_RW);
|
15 | lcd_sendOut(LCD_PORT);
|
16 |
|
17 | /* output high nibble first */
|
18 | LCD_PORT &= ~(1 << LCD_D7);
|
19 | LCD_PORT &= ~(1 << LCD_D6);
|
20 | LCD_PORT &= ~(1 << LCD_D5);
|
21 | LCD_PORT &= ~(1 << LCD_D4);
|
22 | lcd_sendOut(LCD_PORT);
|
23 |
|
24 | if (data & 0x10) LCD_PORT |= (1 << LCD_D4);
|
25 | if (data & 0x20) LCD_PORT |= (1 << LCD_D5);
|
26 | if (data & 0x40) LCD_PORT |= (1 << LCD_D6);
|
27 | if (data & 0x80) LCD_PORT |= (1 << LCD_D7);
|
28 | lcd_sendOut(LCD_PORT);
|
29 | lcd_enable();
|
30 |
|
31 | /* output low nibble */
|
32 | LCD_PORT &= ~(1 << LCD_D7);
|
33 | LCD_PORT &= ~(1 << LCD_D6);
|
34 | LCD_PORT &= ~(1 << LCD_D5);
|
35 | LCD_PORT &= ~(1 << LCD_D4);
|
36 | lcd_sendOut(LCD_PORT);
|
37 |
|
38 | if (data & 0x01) LCD_PORT |= (1 << LCD_D4);
|
39 | if (data & 0x02) LCD_PORT |= (1 << LCD_D5);
|
40 | if (data & 0x04) LCD_PORT |= (1 << LCD_D6);
|
41 | if (data & 0x08) LCD_PORT |= (1 << LCD_D7);
|
42 | lcd_sendOut(LCD_PORT);
|
43 | lcd_enable();
|
44 |
|
45 | /* all data pins high (inactive) */
|
46 | LCD_PORT |= (1 << LCD_D4);
|
47 | LCD_PORT |= (1 << LCD_D5);
|
48 | LCD_PORT |= (1 << LCD_D6);
|
49 | LCD_PORT |= (1 << LCD_D7);
|
50 | lcd_sendOut(LCD_PORT);
|
51 | }
|