cancel
Showing results for 
Search instead for 
Did you mean: 

Interface with ADC via I2C (ADC Part No: TLA2528)

GMano.1
Associate II

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] );
While Debugging we could only get the value as "0x00". Could you please help us with this issue?
 
we have attached the TLA2528 Datasheet below for your reference.
 
 
Thanks & Regards
M. Govind. 

 

4 REPLIES 4
mƎALLEm
ST Employee

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.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
TDK
Super User

Does HAL_I2C_IsDeviceReady return HAL_OK? Start there.

 

If you feel a post has answered your question, please click "Accept as Solution".
Andrew Neil
Super User

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, a@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

 

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
Andrew Neil
Super User

The datasheet says that a read should look like this:

AndrewNeil_0-1751033543127.png

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.