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.

TCA8418: Unable to read the key interrupt

Part Number: TCA8418

hi  TI

    Unable to read the key interrupt, INT pin (input, PULLUP) has not changed, RST (output, high level), please check the schematic diagram and program for any problems,

    Thank you。

soft:

key_buff[0]=0xc0;

HAL_I2C_Mem_Write(&hi2c2,0x68,0x2C,I2C_MEMADD_SIZE_8BIT,&key_buff[0],1,100);

key_buff[0]=0xf0;

HAL_I2C_Mem_Write(&hi2c2,0x68,0x2C,I2C_MEMADD_SIZE_8BIT,&key_buff[0],1,100);

key_buff[0]=0x00;

HAL_I2C_Mem_Write(&hi2c2,0x68,0x2C,I2C_MEMADD_SIZE_8BIT,&key_buff[0],1,100);

key_buff[0]=0x05;

HAL_I2C_Mem_Write(&hi2c2,0x68,0x01,I2C_MEMADD_SIZE_8BIT,&key_buff[0],1,100);

HAL_I2C_Mem_Read(&hi2c2,0x69,0x02,I2C_MEMADD_SIZE_8BIT,&key_buff[1],1,100);//INT_STAT register

if(key_buff[1]==0x1||key_buff[1]==0x2)

{

HAL_I2C_Mem_Read(&hi2c2,0x69,0x03,I2C_MEMADD_SIZE_8BIT,&key_buff[2],1,100);//the Key Lock and Event Counter Register

if(key_buff[2]>0)

key_buff[2]=(key_buff[2]<<4)>>4;

for(uint8_t i=0;i<key_buff[2];i++)

{

HAL_I2C_Mem_Read(&hi2c2,0x69,0x04,I2C_MEMADD_SIZE_8BIT,&key_buff[3],1,100);//KEY_EVENT_A

if(key_buff[3]>8);

}

}

}

  • The pull-up resistors on the I²C lines are missing.

    The code writes three times to register 0x2C. This is probably not intended.

    The condition "key_buff[1]==0x1||key_buff[1]==0x2" will fail if both bits are set; better use "(key_buff[1] & 0x03) != 0".

    I hope the initialization and reading parts of the software are not executed at the same time?

  • hi Clemens

         thanks for your support, I will check it.

  • Hi  Clemens

         1. I2C bus pull-up resistance is not shown in the screenshot, but is actually available;

         2. Software modified;

         3. No

    Q:

        1. ROW and COL pins are not connected, do you need to pull up resistance? Default resistance pull-up? How do I set 0X2C-0X2E?

         2. RESET is initialized to low level, whether it needs to be changed to high level?

        3. Whether the INT circuit connection is correct. If it is correct, pull it up, pull it down and pull it down without pulling it up are all high level. Will it become low level when pressing the key? The actual key test does not change to low level.

           

  • 1. Unused ROW and COL pins can be left open as long as the internal pull-up is enabled.

    2. /RESET must be high for the device to work.

  • Hi Rain,

    I will get back to you by 4pm tomorrow. 

    Regards,

    Tyler

  • Hi  

    The above suggestions have been changed, but no interrupt has been read after executing according to the following software. Please help check. Thank you.

    HAL_GPIO_WritePin(GPIOA, KEY_RST_Pin,GPIO_PIN_SET);

     

    while(1){

        

    HAL_I2C_Mem_Read(&hi2c2,0x69,0x02,I2C_MEMADD_SIZE_8BIT,&key_buff[1],1,0xffff);//INT_STAT register

     

    if((key_buff[1]&0x03)!=0)

    {

    HAL_I2C_Mem_Read(&hi2c2,0x69,0x03,I2C_MEMADD_SIZE_8BIT,&key_buff[2],1,0xffff);//the Key Lock and Event Counter Register

    key_buff[2]=(key_buff[2]<<4)>>4;

    if(key_buff[2]>0)

    {

    do{

     

    HAL_I2C_Mem_Read(&hi2c2,0x69,0x04,I2C_MEMADD_SIZE_8BIT,&key_buff[3],1,0xffff);//KEY_EVENT_A

    if(key_buff[3]>8) key_buff[3]-=8;

     

    }while(key_buff[3]!=0);

    key_buff[1]=0x3;

    HAL_I2C_Mem_Write(&hi2c2,0x69,0x02,I2C_MEMADD_SIZE_8BIT,&key_buff[1],1,0xffff);

    }

     

    }

    }

  • The reset clears all registers, so the interrupts are disabled.

    You have to clear the reset first, then configure the registers, then wait for events.

  • Which registers need to be configured for initialization? Is there a demo for reference?

    Now, I want to check whether the register is configured correctly, Thanks.

  • That depends on what you want to do. At a minimum, you should configure the row/column pins, and enable the interrupts you want.

  • Hi Rain,

    Please check page 29, section 8.6.2.1 of the datasheet. Here you can write to the configuration register how you want to setup the device. GPI event mode, overflow mode, interrupt config, overflow interrupt enable, keypad lock interrupt enable, GPI interrupt enable to host processor, key events interrupt enable to host processor:

    Configure these bits before attempting to read from INT_STAT, KEY_LCK_EC, and KEY_EVENT_A registers. 

    Regards,

    Tyler