capacitive touch CPT112s interface with STM32 using I2C not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-16 5:06 AM - last edited on ‎2025-03-05 1:54 AM by Andrew Neil
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
- Labels:
-
I2C
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-24 7:43 AM
I'm not sure how I can assist any more without actually writing your code for you. Perhaps there is someone physically closer to you who can help with the basics.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-27 11:27 PM
Hi,
I do not want any assistance in writing the code as we are doing it from our side...it more that we wanted to see if you had come across CPT112S chip so that we can get the address issue resolved.we got the I2C working and rest of our module ourselves...nothing to worry.
Thanks and regards
Ravi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-28 4:16 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-29 12:18 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-29 12:19 AM
Just guide me in the way we are reading the INT while we have configured,,will help us a lot
Thanks and regards
Ravi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-30 5:08 AM
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

- « Previous
-
- 1
- 2
- Next »