cancel
Showing results for 
Search instead for 
Did you mean: 

How to implement I2C communication with a sensor like AD7147-1?

PRout.1
Associate II

I followed this example that does i2c communication with TMP102 https://www.digikey.in/en/maker/projects/getting-started-with-stm32-i2c-example/ba8c2bfef2024654b5dd10012425fa23.

In the case of AD7147-1, the module can read up to 13 sensors and I'm trying to use the same with the STM32 Nucleo-F334R8 board. How to frame the bytes? In this case, it has multiple registers and I want to use all the possible sensor readings.0693W00000D0PJAQA3.jpg This above figure shows multiple stages of CDC conversion and below is the I2C address

0693W00000D0PJoQAN.jpg 

Below is the sequential register readback method is given by Analog devices.

0693W00000D0PK3QAN.jpg 

I would appreciate any help in this regard.

A simple template to read the sensor data in a sequential manner shall help a lot.

-Prasanna

2 REPLIES 2

Should be able to find I2C examples for EEPROM and similar devices within the various BSP files for the F3

STM32Cube_FW_F3_V1.10.0\Drivers\BSP\STM32303C_EVAL\stm32303c_eval.c

Should be able to use 16-bit register size, Addr is the Slave, ie (0x54 << 1), and Reg base with the AD7147-1, it can read long runs of data

status = HAL_I2C_Mem_Read(&heval_I2c, Addr, (uint16_t)Reg, RegSize, pBuffer, Length, I2cxTimeout);

Pretty basic stuff by the looks of it. Review descriptions of functions in the HAL library. Grep the examples and BSP directories for "_I2C_" to find other usage

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
PRout.1
Associate II

Hi Tesla,

Thanks for the answer.

I found the example code and while trying to implement the same for AD7147, I'm facing issues because I'm unable to get PAGE size and number.

https://github.com/STMicroelectronics/STM32CubeF3/blob/master/Projects/STM32303C_EVAL/Examples/I2C/I2C_EEPROM/Src/main.c

#defineEEPROM_ADDRESS0 xA4 /* EEPROM M24M01-HR Address */

#defineEEPROM_PAGESIZE 128 /* EEPROM M24M01-HR used */