2022-03-15 07:19 AM
Hi folks
I am currently trying to communicate with the TLV493D-A1B6 3D hall sensor. As board, I'm using the NUCLEO-F103RB. To make sure I didn't mess up any connections or anything else, I verified my setup with an ADS1015 adc which I can read out over I2C. Unfortunately, I am not able to find a valid address whilst sweeping through all possible addresses. I always get "HAL_ERROR" after using the following routine. With my other I2C device, I get 3 valid addresses.
for(i=1; i<255; i++)
{
ret = HAL_I2C_IsDeviceReady(&hi2c1, (uint16_t)(i<<1), 3, 5);
if (ret != HAL_OK) /* No ACK Received At That Address */
{
HAL_UART_Transmit(&huart1, Space, sizeof(Space), 10000);
}
else if(ret == HAL_OK)
{
sprintf(Buffer, "0x%X", i);
HAL_UART_Transmit(&huart1, Buffer, sizeof(Buffer), 10000);
}
}
For further information, any data sheets are available here: https://www.infineon.com/cms/en/product/sensor/magnetic-sensors/magnetic-position-sensors/3d-magnetics/tlv493d-a1b6/
Thanks a lot for your help and best regards
Solved! Go to Solution.
2022-03-22 07:53 AM
Here I am again. My code works now :D
As described in the data sheet, the I2C communication can only start after the SCL interrupt, driven by the slave, is over. I currently fixed this issue by starting the first read command after I receive an interrupt on the SCL line. After that, I disable the INT bit in the register 0x11. With this setting, I can receive data with the following command:
HAL_I2C_Master_Receive_IT(&hi2c1, ADDRESS, rbuffer, sizeof(rbuffer));
2022-03-17 12:44 AM
It seems to be a hardware issue. I am currently working on it to figure out what exactly the problem is.
2022-03-21 07:24 AM
Unfortunately, I still did not figure out what exactly the error is. I managed to communicate with my sensor over I2C with an Arduino UNO board. Whilst using my ST Board, I observed that my sensor is pulling down the SCL line periodical. When I disconnect the SCL line to the sensor it, everything is fine, except the ACK is not sent, because my sensor has obviously no CLK.
I also try to change the GPIO mode, which did not realy help because it seems like the slave can not pull down the data line:
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
// changed to
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
I would appreciate any help or hints.
2022-03-22 07:53 AM
Here I am again. My code works now :D
As described in the data sheet, the I2C communication can only start after the SCL interrupt, driven by the slave, is over. I currently fixed this issue by starting the first read command after I receive an interrupt on the SCL line. After that, I disable the INT bit in the register 0x11. With this setting, I can receive data with the following command:
HAL_I2C_Master_Receive_IT(&hi2c1, ADDRESS, rbuffer, sizeof(rbuffer));