Skip to main content
RShiv.1
Associate III
December 16, 2021
Question

capacitive touch CPT112s interface with STM32 using I2C not working

  • December 16, 2021
  • 15 replies
  • 4588 views

Hi,

As we were trying to interface CPT112s capacitive touch controller with STM32 using I2C,

we were able to get the I2C working...but I was not able to get touch event (either 1 or any high value)

Below is my address reference for both device and memory.

uint16_t DevAddress1 = 0xC0<<1;

uint16_t MemAddress1 = 0xC0200000;

uint8_t mac_id_buf[6] = "";

char print_msg[100] = "";

 

if(HAL_OK == HAL_I2C_IsDeviceReady(&hi2c1,DevAddress1,200,2000)){

if(HAL_OK == HAL_I2C_Mem_Read(&hi2c1,DevAddress1,MemAddress1,I2C_MEMADD_SIZE_8BIT,(uint8_t*)&mac_id_buf[0],0x0006,HAL_MAX_DELAY)) {

strcpy(print_msg,"SUCCESS HAL_I2C_Mem_Read\r\n");

HAL_UART_Transmit(&huart5,(uint8_t*)print_msg,strlen(print_msg),1000);

sprintf(print_msg,"%X %X %X %X %X %X\r\n", mac_id_buf[0],mac_id_buf[1],mac_id_buf[2],mac_id_buf[3],mac_id_buf[4],mac_id_buf[5]);

HAL_UART_Transmit(&huart5,(uint8_t*)print_msg,strlen(print_msg),1000);

}

else{

strcpy(print_msg,"ERROR in HAL_I2C_Mem_Read()\r\n");

}

}

else{

strcpy(print_msg,"ERROR in HAL_I2C_IsDeviceReady()\r\n");

}

Kindly let me know what changes needed to be done so that I can get the capactive sense value .

Thanks and regards

Ravi chandra

This topic has been closed for replies.

15 replies

RShiv.1
RShiv.1Author
Associate III
December 28, 2021

Hi,

I have attached the file where the INTERRUPT pin (KEYPAD_INT) when this is low ..then I am reading from I2C_Master_Receive()...so when INT works this should work.

Just let me know the checking is fine.

Thanks

Ravi

RShiv.1
RShiv.1Author
Associate III
December 29, 2021

Hi,

Any udpate on the INT pin way we have wriiten..we are using PB1 which we have configured in CUBEMX ,then generated the code..the name we have given is KEYPAD INT..which we are trying to read when it is low and then read the I2C data...hope this is fine..kindly let us know. I have attached the code in my previous post.

Thanks

Ravi

RShiv.1
RShiv.1Author
Associate III
December 29, 2021

Just guide me in the way we are reading the INT while we have configured,,will help us a lot

Thanks and regards

Ravi

RShiv.1
RShiv.1Author
Associate III
December 30, 2021

Hi ,

attached is the INT pin code for Keypad which we have connected to PB1...I have also written the HAL_GPIO_call back...we have forced the INT...but the Interrupt is not seen.Kindly let me know whether the call back is correct and also how we can read the INT pin.

Thanks

Ravi