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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-01-18 09:44 AM
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
Solved! Go to Solution.
- Labels:
-
I2C
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-01-18 10:28 AM
HAL_I2C_Mem_Read(). See https://forum.digikey.com/t/using-the-stm32cube-hal-i2c-driver-in-master-mode/15122#hal_i2c_mem_read-7
hth
KnarfB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-01-18 10:28 AM
HAL_I2C_Mem_Read(). See https://forum.digikey.com/t/using-the-stm32cube-hal-i2c-driver-in-master-mode/15122#hal_i2c_mem_read-7
hth
KnarfB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-01-18 12:51 PM
Simple: use HAL_I2C_MemoryRead().
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-01-18 12:56 PM
Thanks. I think that will work. Don't understand why I didn't look at that.