This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
void TCA8418::initialize() { //initialize communication with TCA84818 i2c.frequency(100000); char cmd[2]; cmd[0] = REG_CFG; //pointer byte to CFG register cmd[1] = 0x91; //data for CFG register KE_IEN set to 1 if ( i2c.write(KB_BASEADRS,cmd, 2) == I2C_ACK ) { //initiate write cycle and check for ACK //intialize all registers from TCA8418 here cmd[0] = REG_INT_STAT; //pointer byte to Interrupt Status Register cmd[1] = 0x01; //Reset KE-INT flag i2c.write(KB_BASEADRS,cmd, 2 ); //Write to Interrupt Status Register from TCA4818 //Set TCA8418 to Keypad mode cmd[0]=REG_KP_GPIO1; //KP_GIO1 cmd[1]=0x0F; //Set to Keypad mode i2c.write(KB_BASEADRS,cmd, 2); cmd[0]=REG_KP_GPIO2; //KP_GIO2 cmd[1]=0xFF; //Set to Keypad mode i2c.write(KB_BASEADRS,cmd, 2); cmd[0]=REG_KP_GPIO3; //KP_GIO3 cmd[1]=0x00; //Set to Keypad mode i2c.write(KB_BASEADRS,cmd, 2); //Set TCA8418 to Keypad mode cmd[0]=REG_DEBOUNCE_DIS1; //KP_GIO1 cmd[1]=0x0F; //Set to Keypad mode i2c.write(KB_BASEADRS,cmd, 2); cmd[0]=REG_DEBOUNCE_DIS2; //KP_GIO2 cmd[1]=0xFF; //Set to Keypad mode i2c.write(KB_BASEADRS,cmd, 2); cmd[0]=REG_DEBOUNCE_DIS3; //KP_GIO3 cmd[1]=0x00; //Set to Keypad mode i2c.write(KB_BASEADRS,cmd, 2); } else { //No response from TCA8418 keyboard chip // FAIL = 1; //Switch on FAIL indicator } } char TCA8418::GET_KEY() { // Key_led = !Key_led; // : toggle LED 2 char cmd[2]; //Read interrupt status flag char key_hit_ID=0; ReadReg(REG_INT_STAT); while (ReadReg(REG_KEY_LCK_EC)) { //Read Key Lock and Event Counter key_hit_ID = int(ReadReg(REG_KEY_EVENT_A)); //Keypress --> read data from keybuffer if (key_hit_ID & 0x80) release=0; else release=1; } //Reset interrupt flag cmd[0] = REG_INT_STAT; //pointer byte to Interrupt Status Register cmd[1] = 0xFF; //Reset KE-INT flag i2c.write(KB_BASEADRS,cmd, 2); return key_hit_ID; }
Yes, there is nothing wrong on the I2C side, it read the same setup out. Only different is that it behaves like no key has been pressed. No interrupt and the fifo register remains telling, that there is no new keys.
It look like its the kapacity copling to my led output, that kills the scan. No I just do a "manual" scan, using GPIO.