Hi,
Please let me know if this question is appropriate in this forum.
I'm having trouble reading a register in a slave through I2C communication.
Slave: bq25895 http://www.ti.com/lit/ds/symlink/bq25895.pdf
IDE: Eclipse Neon
In main:
while (1){
HAL_StatusTypeDef status = HAL_OK;
uint16_t return_value = 0;
status = HAL_I2C_Mem_Read(&hi2c1, 0xD4, (uint16_t)(0x07), I2C_MEMADD_SIZE_8BIT, &return_value, 1, 1000);
if(status != HAL_OK) { printf ("Error");}
else {printf ("No error");}
}
Problem: The I2C_FLAG_AF is set since there is no ACK from the slave.
Tracing the problem down:
/* Send Slave Address and Memory Address */
if (I2C_RequestMemoryRead(hi2c, DevAddress, MemAddress, MemAddSize, Timeout, tickstart) != HAL_OK)
/* Wait until TXIS flag is set */
if (I2C_WaitOnTXISFlagUntilTimeout(hi2c, Timeout, Tickstart) != HAL_OK)
/* Check if a NACK is detected */
if (I2C_IsAcknowledgeFailed(hi2c, Timeout, Tickstart) != HAL_OK)
/* Check if NACK is set inside of I2C_IsAcknowledgeFailed() */
if (__HAL_I2C_GET_FLAG(hi2c, I2C_FLAG_AF) == SET)
How do I fix this problem?
I'm new to this whole thing, so I appreciate any helps.
Thanks.