Skip to main content
FD.1
Associate
June 12, 2020
Solved

How to implement repeated start for HAL_I2C_Mem_Read and HAL_I2C_Mem_Write?

  • June 12, 2020
  • 3 replies
  • 1332 views

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.

This topic has been closed for replies.
Best answer by Pavel A.

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

-- pa

3 replies

Pavel A.
Pavel A.Best answer
Super User
June 12, 2020

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

-- pa

Piranha
Principal III
June 13, 2020

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
FD.1Author
Associate
June 13, 2020

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.