Witam,
Otó¿ mam klawiaturê i nie mogê odczytaæ (mimo ¿e powinienem) kolumny nr 3 (na sch, w prog. kolumna nr 1)... Schemat:
void Init(void) { // Interfejs I2C DDR(I2C_SDAPORT) |= 1 << I2C_SDA; DDR(I2C_SCLPORT) |= 1 << I2C_SCL; PORT(I2C_SDAPORT) |= 1 << I2C_SDA; PORT(I2C_SCLPORT) |= 1 << I2C_SCL; // zaraz po inicjacji wy¶lij zera na wyj¶cia PCF'a i2c_send8574(PCF8574_ADDR,0x00);
// Klawiatura PORT(SW_PORT) = 0xff; // "1" na wszystkie przyciski // Zera bêd± siê pojawiaæ na wierszach ,a czytane bêd± kolumny :) DDR(SW_PORT) |= 1 << SW_ROW1 | 1 << SW_ROW2 | 1 << SW_ROW3 | 1 << SW_ROW4 | 1 << SW_ROW5; DDR(SW_PORT) &= ~(0xe0); // pb5,pb6,pb7 jako wejscie
// Diody PORT(LED_PORT) |= 1 << LED1 | 1 << LED2 | 1<<LED3; PORT(LED_PORT) &= ~(1 << LED_R | 1 << LED_G);
DDR(LED_PORT) |= 1 << LED1 | 1 << LED2 | 1 << LED3 | 1 << LED_R | 1 << LED_G;
LED_G_ON; }
uint8_t key_scan(void) { PORT(SW_PORT) |= 0xff; uint8_t temp=16; // pocz±tek skanowania - odczyt kolumnowy // wiersz 1 PORT(SW_PORT) &= ~(1 << SW_ROW1); // ustaw "0" na wierszu if (!(PIN(SW_PORT) & 0x80)) { // kolumna 1 temp = 10; } else if (!(PIN(SW_PORT) & 0x40)) { // kolumna 2 temp = 0; } else if (!(PIN(SW_PORT) & 0x20)) { temp = 11; } PORT(SW_PORT) |= 1 << SW_ROW1; // ustaw "1" na wierszu // wiersz 2 PORT(SW_PORT) &= ~(1 << SW_ROW2); // ustaw "0" na wierszu if (!(PIN(SW_PORT) & 0x80)) { // kolumna 1 temp = 9; } else if (!(PIN(SW_PORT) & 0x40)) { // kolumna 2 temp = 8; } else if (!(PIN(SW_PORT) & 0x20)) { temp = 7; } PORT(SW_PORT) |= 1 << SW_ROW2; // ustaw "1" na wierszu // wiersz 3 PORT(SW_PORT) &= ~(1 << SW_ROW3); // ustaw "0" na wierszu if (!(PIN(SW_PORT) & 0x80)) { // kolumna 1 temp = 6; } else if (!(PIN(SW_PORT) & 0x40)) { // kolumna 2 temp = 5; } else if (!(PIN(SW_PORT) & 0x20)) { temp = 4; } PORT(SW_PORT) |= 1 << SW_ROW3; // ustaw "1" na wierszu // wiersz 4 PORT(SW_PORT) &= ~(1 << SW_ROW4); // ustaw "0" na wierszu if (!(PIN(SW_PORT) & 0x80)) { // kolumna 1 temp = 3; } else if (!(PIN(SW_PORT) & 0x40)) { // kolumna 2 temp = 2; } else if (!(PIN(SW_PORT) & 0x20)) { temp = 1; } PORT(SW_PORT) |= 1 << SW_ROW4; // ustaw "1" na wierszu // wiersz 5 PORT(SW_PORT) &= ~(1 << SW_ROW5); // ustaw "0" na wierszu if (!(PIN(SW_PORT) & 0x80)) { // kolumna 1 temp = 14; } else if (!(PIN(SW_PORT) & 0x40)) { // kolumna 2 temp = 13; } else if (!(PIN(SW_PORT) & 0x20)) { temp = 12; } PORT(SW_PORT) |= 1 << SW_ROW5; // ustaw "1" na wierszu return temp; } </code>
Je¶li zrobi³em jaki¶ g³upi b³±d to proszê o info i nie ¶miaæ siê :> gdy¿ dopiero zaczynam pisaæ w c :))