Skip to content

iic IP driver calls the SendHandler before the IP has actually finished the send. #370

@bbain

Description

@bbain

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions