I am using the iic IP to connect to a sensor. When writing the configuration, the callback (set by XIic_SetSendHandler) gets called before the last byte has actually been sent. I use this callback to schedule the next operation which fails with XST_IIC_BUS_BUSY as the IP has yet to finish sending the last byte.
My basic operation is:
XIic_SetSendHandler(.... callback ...)
XIic_MasterSend(....)
Wait for callback.
// This fails with a XST_IIC_BUS_BUSY.
XIic_MasterSend(....)
The callback is called via the IRQ for the XIIC_INTR_BNB_MASK (bus not busy) on the last byte to be sent (see). The problem seems to be that the BNB interrupt has already been set from when the bus was idle before the last byte was sent (in my case this is the first operation performed after a reset). Thus the XIIC_INTR_BNB_MASK immediately triggers even though the last byte is still being sent.
It seems that the source should be calling XIic_ClearEnableIntr rather than XIic_EnableIntr to ensure that BNB is only triggered after the last byte is sent.
When I made this change the SendHandler is called after the last byte has been sent and as such my second XIic_MasterSend works as the bus is actually idle.
I am using the iic IP to connect to a sensor. When writing the configuration, the callback (set by
XIic_SetSendHandler) gets called before the last byte has actually been sent. I use this callback to schedule the next operation which fails withXST_IIC_BUS_BUSYas the IP has yet to finish sending the last byte.My basic operation is:
The callback is called via the IRQ for the
XIIC_INTR_BNB_MASK(bus not busy) on the last byte to be sent (see). The problem seems to be that the BNB interrupt has already been set from when the bus was idle before the last byte was sent (in my case this is the first operation performed after a reset). Thus theXIIC_INTR_BNB_MASKimmediately triggers even though the last byte is still being sent.It seems that the source should be calling
XIic_ClearEnableIntrrather thanXIic_EnableIntrto ensure that BNB is only triggered after the last byte is sent.When I made this change the
SendHandleris called after the last byte has been sent and as such my secondXIic_MasterSendworks as the bus is actually idle.