2020-01-30 10:23 AM
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.
2020-01-30 12:51 PM
I found my own answer. I had an interrupt issue as they were not properly enabled.
2020-10-14 09:04 AM
do you remember which interrupt you had to enable? i have exactly the same problem
2020-10-15 04:33 AM
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.