Witam,
Morduje LCD przez PCF8574 :) o ile inicjacja dzia³a bez problemu to przesy³anie tekstu (jak i pozosta³e operacje nie dzia³aj±) :/ mo¿e kto¶ "rzuci okiem" kto robi³ takie co¶:
// PinoutPCF: P0-P3 -> D4-D7, P4 -> RS, P5 -> R/W (not used), P6 -> EN2 (not used), P7 -> EN <code>
//globalna zmienna trzymaj±ca stan portu pcf'a uint8_t lcd_pcf_port;
void i2c_lcd_init(void) { delay1ms(250); lcd_pcf_port = 0xef; // RS=0 i2c_send8574(adr,lcd_pcf_port); delay1us(10); i2c_lcd_sendHalf(0x03,adr); // D4,D5 = 11 - data 8bit ; wg. noty hd44780 trzeba 3x wyslac to polecenie delay1ms(10); i2c_lcd_sendHalf(0x03,adr); delay1us(500); i2c_lcd_sendHalf(0x03,adr); delay1us(500); i2c_lcd_sendHalf(0x02,adr); // 4bit data delay1us(500); // tryb 4bit w³±czony i2c_lcd_command(0x28,adr); // 4bit data - DL=0, 2 lines lcd - N=1, char
5x8 - F=0 i2c_lcd_command(0x08,adr); // Off: display, cursor, blinking i2c_lcd_cls(adr); i2c_lcd_command(0x06,adr); // Cursor shift: incr I/D=1, display shift off S=0 i2c_lcd_command(0x0c,adr); // On: display; Off: cursor, blinking // jak nawet w±cze wy¶wietlanie kursora (0x0c|0x02) i/lub miganie (0x0c|0x01) to jest dobrze i dzia³a } </code>
Mój problem musi gdzie¶ le¿eæ ko³o funkcji command i data ale ja nic nie widze co robi³ bym ¼le :/
I funkcje wysy³aj±ce dane i polecenia: <code>
void i2c_lcd_command(uint8_t command, uint8_t adr) { lcd_pcf_port &= 0xef; // RS=0 i2c_send8574(adr,lcd_pcf_port); delay1us(100); i2c_lcd_send(command, adr); delay1us(100); }
void i2c_lcd_data(uint8_t data, uint8_t adr) { lcd_pcf_port |= 0x10; // RS=1 i2c_send8574(adr,lcd_pcf_port); //delay1us(100); i2c_lcd_send(adr,data); } // ----------------- Pozostale funkcje void i2c_lcd_cls(uint8_t adr) { i2c_lcd_command(0x01, adr); // lcd CLS delay1ms(10); }
void i2c_lcd_home(uint8_t adr) { i2c_lcd_command(0x02, adr); // lcd_cursor: home delay1ms(15); }
void i2c_lcd_setPos(uint8_t yy, uint8_t xx, uint8_t adr) { uint8_t n=0; if (yy == 1) n = 0; if (yy == 2) n = 64; if (yy == 3) n = 12; if (yy == 4) n = 76; n += xx; i2c_lcd_command((0x80|n), adr); // Set DDRAM addr }
// pisanie void i2c_lcd_str(char* str, uint8_t adr) { char znak; while(0 != (znak = *(str++))) i2c_lcd_data(znak, adr); }
</code>
Aha i funkcja send8574 jest dobra gdy¿ ca³y czas z niej korzystam (od pocz±tku jej napisania).