cancel
Showing results for 
Search instead for 
Did you mean: 

Why does the I2C state remain in HAL_I2C_STATE_BUSY_TX when an access is completed.

BCrow.1
Associate II

I am doing a DMA based I2C transmit using HAL_I2C_Master_Transmit_DMA and am seeing an issue with the state of the I2C. The transfer completes as expected as confirmed using an oscilloscope on the pins. However, the state of the I2C gets switched to HAL_I2C_STATE_BUSY_TX and remains that way. As such any subsequent transaction returns HAL_BUSY and doesn't complete. The I2C ISR register has only TXE and STOPF asserted, which I think is expected behaviour. The BUSY bit is not set, so I think the hardware is fine and ready for another transaction, but the HAL is out of synch with it. What clears the busy status when a DMA transfer is done? Thanks for any insights into this issue.

3 REPLIES 3
BCrow.1
Associate II

I found my own answer. I had an interrupt issue as they were not properly enabled.

deep_rune
Associate III

do you remember which interrupt you had to enable? i have exactly the same problem

BCrow.1
Associate II

If I remember correctly it was the I2C event interrupt. You need the DMA interrupts enabled as well to manage the data with the callback function for those, but if the event interrupt isn't enabled you'll get stuck in the busy state. I am using the STMCubeIME tools and I have found that the CubeMX within it has a bit of a mind of its own when it comes to enabling interrupts. Each time I open the CubeMX file is enables interrupts that I want disabled so be careful of that. I always double check my interrupt settings before saving the configuration.