2025-06-27 3:10 AM - last edited on 2025-06-27 3:17 AM by mƎALLEm
Hai..,
We are using a custom board with STM32H743IIT6 soldered to it. For our application, we need more Analog Inputs so we have used TLA2528 chip. Below is the code for it..
tx_buf[0] = TLA2528_PIN_CFG;
tx_buf[1] = 0x00;
HAL_I2C_Master_Transmit(&hi2c4, TLA2528_I2C_ADDR, tx_buf, 2, HAL_MAX_DELAY);
tx_buf[0] = 0x10;
tx_buf[1] = 0x00;
HAL_I2C_Master_Transmit(&hi2c4, TLA2528_I2C_ADDR, tx_buf, 2, HAL_MAX_DELAY);
tx_buf[0] = TLA2528_CHL_SEL;
tx_buf[1] = 0x00;
HAL_I2C_Master_Transmit(&hi2c4, TLA2528_I2C_ADDR, tx_buf, 2, HAL_MAX_DELAY);
tx_buf[0] = 0x01;
tx_buf[1] = 0x08;
HAL_I2C_Master_Transmit(&hi2c4, TLA2528_I2C_ADDR, tx_buf, 2, HAL_MAX_DELAY);
HAL_Delay(20);
HAL_I2C_Master_Receive(&hi2c4, TLA2528_I2C_ADDR | 0x01 ,rx_buf, 2, HAL_MAX_DELAY);
result = (rx_buf[0] << 8 | rx_buf[1] );
2025-06-27 3:19 AM
Hello,
In next time please use </> button to share your code. See How to insert source code.
I've edited your post.
Thank you for your understanding.
2025-06-27 6:49 AM
Does HAL_I2C_IsDeviceReady return HAL_OK? Start there.
2025-06-27 7:01 AM - edited 2025-06-27 7:07 AM
Please provide more details - see How to write your question to maximize your chances to find a solution.
@GMano.1 wrote:We are using a custom board
Therefore you need to post the schematic.
Does it have correct pullups?
Have you used an oscilloscope to check that the signals are good ?
Have you an analyser to check that the bus transactions are correct ?
Are you even getting an ACK from the device? HAL_I2C_IsDeviceReady will check this, as @TDK suggested.
BTW: rather than use magic numbers, named symbolic symbols would make your code easier to read & maintain.
TI provide a header file on their Product Page:
https://www.ti.com/product/TLA2528#design-development:~:text=SUPPORT%20SOFTWARE,C%20Header%20File
2025-06-27 7:13 AM
The datasheet says that a read should look like this: