cancel
Showing results for 
Search instead for 
Did you mean: 

How to implement repeated start for HAL_I2C_Mem_Read and HAL_I2C_Mem_Write?

FD.1
Associate II

Hello,

i want to communicate with an AD7998, to convert 8 analog to digital channels. The communication i use is I2C. I am using the HAL library.

According to the adc manual i need a repeated start, after writing to the address pointer byte. So i had tried to use HAL_I2C_Mem_Read, but that isn't working.

Are there other functions in the i2c HAL library to implement a repeated start?

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Pavel A.
Evangelist III

Yes, HAL_I2C_Mem_Read does a repeated start. If it doesn't work, check parameters. Use a logic analyzer.

-- pa

View solution in original post

3 REPLIES 3
Pavel A.
Evangelist III

Yes, HAL_I2C_Mem_Read does a repeated start. If it doesn't work, check parameters. Use a logic analyzer.

-- pa

Piranha
Chief II

So, your approach is, if something doesn't work, then:

  1. Don't fix the actual problem. Instead try something other.
  2. Choose randomly one feature (repeated start) and try to find a "solution" for it.

And, as you can see, that careless approach doesn't work... Instead there are two other approaches that actually work - either you carefully check everything or take an oscilloscope or logic analyzer and debug it.

FD.1
Associate II

Hi,

thanks for your reply. It works now. My ADC just didn't transfer the register values correctly. I disconnected it from the supply for a while, now it works as it should.

@ Pavel A. Good to know that, thank you.