Skip to main content
ABah.1
Associate
July 23, 2020
Question

HAL_I2C_Master_Sequential_Transmit_IT doesnt return data in data buffer

  • July 23, 2020
  • 10 replies
  • 3799 views

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??

This topic has been closed for replies.

10 replies

TDK
July 23, 2020

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
ABah.1Author
Associate
July 25, 2020

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
ABah.1Author
Associate
July 25, 2020

Oscope data

Piranha
Principal III
July 25, 2020

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
ABah.1Author
Associate
July 25, 2020

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

Piranha
Principal III
July 25, 2020

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

ABah.1
ABah.1Author
Associate
July 25, 2020

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

Piranha
Principal III
July 25, 2020

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

ABah.1
ABah.1Author
Associate
July 25, 2020

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

Bad answer

Piranha
Principal III
July 25, 2020

I already said multiple times that it does not generate STOP condition in the middle and does exactly what you and 99% use cases need. Enable the cerebellar cortex feature!