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.

TCA8418E: TCA8418 stop to read keyboard

Part Number: TCA8418E
Other Parts Discussed in Thread: TCA8418,
Description of Error with TCA8418
I have two IC on the same I2c network. The first is a PCA9685 PWM controller and the other is the TCA8418E. If I run the code for the on or the other, there is no problems. I can also run it in a mode, where, when I press a buttom I turn on a pwm output, and then on nest timer slot turn it of. 
The problem arise when I make it do a bit more. 
The timer is 10 ms. so when a key is pressed I turn the pwm to 100%. after 5 ticks I turn it dowm to 50% then 25 tick later I switch it of.
I can run for about 30-150 keypress, then the colums goes into a HI imp state
My theory is that i has to do with activ I2C bus and a interrupt fra a key.
When the interrupt comes frrom the tca8418 I just it a bit in software and wait to net timetick to handle it.
After it stops I can still read register of the TCA8418, and they are the same. It just stops reading. And if the colums are in HI imp, then it dont know the a key is pressed.
Here is how they look, when no key is pressed and when a key is pressed.
Normally it looks like this:
Schematic:
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;
}

  • Hello Gert,
    Can you tell me if you are able to catch the event when the outputs go high-Z? Do you also catch the I2C traffic as that happens?
    -Francis Houde
  • 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.