cancel
Showing results for 
Search instead for 
Did you mean: 

How to read data from MUX using I2C Write/Read

RSai.2
Associate

Greetings,

I am using STM32L431RC MCU, and I'm trying to read the MUX for reading temperatures using I2C 3 interface, by using the Device address of the MUX, Acknowledge from the device and my data as the parameters in the format as specified in the image.

And I'm using the HAL_Master_Transmit function to write the slave, but I'm getting wrong values in my buffer.

The function which I have used is right or I should follow a different function?0693W00000D1FQYQA3.pngKindly Help.

#[STM32 MCUs]​ #stm32L431RC

Thanks and Regards,

Rohith Sai

3 REPLIES 3
TDK
Guru

What chip are you interfacing with?

HAL_Master_Transmit isn't a function.

HAL_I2C_Master_Transmit will write data. HAL_I2C_Master_Receive will read data.

You can also use HAL_I2C_Mem_Read/HAL_I2C_Mem_Write which can be convenient if interfacing with registers on the chip.

Ensure your slave address is left-shifted.

If you feel a post has answered your question, please click "Accept as Solution".
RSai.2
Associate

Greetings,

I am using ADG728 Mux , but when using HAL_I2C_Mem_Read/HAL_I2C_Mem_Write I should pass the register address as a parameter where in this case I dont have any registers to be read or written, my objective is to write data into the mux by passing S pin as a data,

Kindly Help.

Regards,

Rohith Sai

TDK
Guru

From page 10 of the datasheet, to interface with the chip you should write or read 1 byte. So use HAL_I2C_Master_Transmit and HAL_I2C_Master_Receive.

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