cancel
Showing results for 
Search instead for 
Did you mean: 

Connect to TLV493D-A1B6 over I2C

Jiimmy
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions
Jiimmy
Associate II

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));

0693W00000KdZNmQAN.png

View solution in original post

3 REPLIES 3
Jiimmy
Associate II

It seems to be a hardware issue. I am currently working on it to figure out what exactly the problem is.

Jiimmy
Associate II

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.

Jiimmy
Associate II

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));

0693W00000KdZNmQAN.png