STM32F103C6T6A I2C interface not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-13 10:42 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-13 10:45 PM
attached is the code ..I am using STMcubeID to run the I2C..I am trying to access sensor data using STM32 along with sensiron chip...but I I2C is not working...Let me know if you have any idea
uint16_t DevAddress = 0x61 << 1;
uint16_t MemAddress = 0x0036;
uint8_t env_var[6] = "";
char print_msg[100] = "";
uint16_t ret ;
if (HAL_OK == HAL_I2C_IsDeviceReady(&hi2c1, DevAddress, 200, 2000)) {
strcpy(print_msg, "SUCCESS HAL_I2C_Device_Read \n");
HAL_UART_Transmit(&huart1, (uint8_t*) print_msg,strlen(MSG),1000);
if (HAL_OK == HAL_I2C_Mem_Read(&hi2c1, DevAddress, MemAddress,I2C_MEMADD_SIZE_8BIT, (uint8_t*) &env_var[0],
0x0006, HAL_MAX_DELAY)) {
strcpy(print_msg, "SUCCESS HAL_I2C_Mem_Read\r\n");
HAL_UART_Transmit(&huart1, (uint8_t*) print_msg,
strlen(print_msg), 1000);
sprintf(print_msg, "%X %X %X %X %X %X\r\n", env_var[0],
env_var[1], env_var[2], env_var[3], env_var[4],
env_var[5]);
HAL_UART_Transmit(&huart1, (uint8_t*) print_msg, strlen(MSG),1000);
} else {
strcpy(print_msg, "ERROR in HAL_I2C_Mem_Read()\r\n");
HAL_UART_Transmit(&huart1, (uint8_t*) print_msg, strlen(MSG),1000);
}
} else {
strcpy(print_msg, "\n ERROR in HAL_I2C_IsDeviceReady()\r\n");
HAL_UART_Transmit(&huart1, (uint8_t*) print_msg, strlen(MSG),1000);
}
regards
Ravi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-13 10:46 PM
ANy configuration needs to be done using STM cube Mx which is missing kinfly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-13 10:48 PM
SCD30 interface description document attached...0x61 is the I2C address ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-14 12:42 AM
before review of SW code, would you confirm that I2C bus is well pulled up by resistors? and more detail information may be helpful instead of "not working". for example NO ACK from sensor or something else.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-14 12:46 AM
yes I2C is well pulled up using 4.7 K resistors and on probing also the line is showing 3.3v...when oscilloscope is connected no activity is seen on the bus...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-14 01:20 AM
we would like to confirm whether we have missed anything on the I2C configuration on STMcubeMx ..
Any IDE issue seen here...let us know...thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-14 09:55 AM
Any update on this will be help us ..Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-14 10:25 PM
Hi ,
Just wanted to know if there needs to be change in S/W ...so that we can communicate with the sensor.
Let me know.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-15 01:11 AM
Hi,
I even tried with below code..even then why is I2C not passing..
uint16_t DevAddress = 0x61 << 1;
uint16_t MemAddress = 0x0036;
uint8_t env_var[6] = "";
char print_msg[200] = "";
uint16_t ret ;
ret = HAL_I2C_Master_Transmit(&hi2c1, DevAddress, env_var, 2, HAL_MAX_DELAY);
if ( ret != HAL_OK )
{
strcpy(print_msg, "\n\r ERROR in HAL_I2C_Master_Tx() \r\n");
HAL_UART_Transmit(&huart1, (uint8_t*) print_msg, strlen(MSG),1000);
} else {
strcpy(print_msg, "success in HAL_I2C_Master_Tx() \r\n");
HAL_UART_Transmit(&huart1, (uint8_t*) print_msg, strlen(MSG),1000);
}
Kindly let me know.
regards
Ravi