cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_I2C_Master_Sequential_Transmit_IT doesnt return data in data buffer

ABah.1
Associate II

Hi all

I want to read i2c data of bme280 sensor. I must read it sequential as follows:

Start

Slave address ack

Internal register address Ack

​Repeated start

Slaveaddress ack

Data to read

Stop

​I do that and every thing is ok in logic onalyzer. For example chip id is read correctly in logic analyzer but HAL_I2C_Master_Sequential_Transmit_IT function does not update data in recieve buffer.

How can i solve this problem??

10 REPLIES 10
TDK
Guru

HAL_I2C_Master_Sequential_Transmit_IT is a transmit function. It doesn't receive data.

You'll need to use HAL_I2C_Master_Seq_Receive_IT to receive data.

If you still have issues, post your code and logic analyzer data.

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

Yes youre right and i had used recieve function. My code image and osciloscope data are attached as you seen in oscope data i am reading 0x60 as id of bme280 sensor which is correct but it is not updated in Rdata buffer

ABah.1
Associate II

Oscope data

Piranha
Chief II

For register reading one must use HAL_I2C_Mem_Read...(), not those separate functions, which put stop bit in the middle of transfer.

ABah.1
Associate II

I should use the following relation to read data

Start

Slave addr

Internal reg addr

Repeated start

Slave addr

Reading n byte

Stop

Beacau oof need to repeat start i have used sequential functions which are ok.

Hal_i2c_mem_read doesnt support above hirerchy

You're wrong - it does it all in a single call because that's the whole purpose of that function!

ABah.1
Associate II

Could you please write me the format which i must use from. Hal_i2c_mem_read for use in repeat start mode

Piranha
Chief II

Just use HAL_I2C_Mem_Read_IT() to read the device registers. It's not even clear what you cannot understand here...

ABah.1
Associate II

I can understand but it generates stop. However we need repeat start.

Bad answer