2022-02-18 02:28 AM
Hi,
I have a question about HAL_I2C_Master_Transmit (I2C_HandleTypeDef * hi2c, uint16_t DevAddress, uint8_t* pData, uint16_t Size, uint32_t Timeout);
I see the second field is a pointer to a 16 bit integer. However the device I am trying to interface must acknowledge between the first and the second byte.
Can you help me in properly setting the HAL ? Attached the figure describing the I2C operating mode of the slave device. I am using nucleo l476rg as a master device
Thanks
Regards
2022-02-18 06:28 AM
ACKs are handled by the peripheral as part of the protocol. You don't need to add "wait for ACK/NACK" to your code anywhere.
The second field is a 16-bit integer (not a pointer), but if you're in 7-bit address mode, only the lower byte of this will be used.
For the image you linked, you would use HAL_I2C_Master_Transmit with Size=2, and make the first byte at pData be "Frame 2: Instruction Byte" in the figure and the second byte would be "Frame 3: Data Byte". The DevAddress parameter should be 0b010110X0 where X is the AD0 bit.