Skip to main content
RCooke88
Associate III
January 18, 2023
Solved

To read a word via I2C I need to add a second start condition to the procedure. What would be the easiest way to accomplish this?

  • January 18, 2023
  • 3 replies
  • 1157 views

From the datasheet from the slave device: "First the host must write a command to the slave device. Then it must follow that command with a repeated start condition to denote a read from that device's address. The slave then returns two bytes of data.

Note that there is not a stop condition before the repeated start condition, and that a "Not Acknowledge" signifies the end of the read transfer."

The data format:

S - Device Addr - Wr - A Cmd Code - A - S - Device Addr - Rd - A - Data Byte Low - A - Data High - !A - P

The Slave's responses are underlined.

Any ideas?

Thanks,

Richard

This topic has been closed for replies.

3 replies

KnarfB
KnarfBBest answer
Super User
January 18, 2023
gbm
Lead III
January 18, 2023

Simple: use HAL_I2C_MemoryRead().

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice
RCooke88
RCooke88Author
Associate III
January 18, 2023

Thanks. I think that will work. Don't understand why I didn't look at that.