how to terminate I2C master-receive transaction?
target CPU: STM32F427IG
I set up STM32F427IG as master receiver via DMA.
I wait on "DMA_GetFlagStatus(I2Cx_DMA_STREAM_RX, I2Cx_RX_DMA_TCFLAG" to figure out if I received what was sent.
After running for 20 minutes or so, I2Cx_RX_DMA_TCFLAG flag does not get set within the timeout period I had defined.
When I2Cx_RX_DMA_TCFLAG does not get set within my timeout period, I want to cancel this transaction. To terminate this transaction I believe I need to send Nack to the transmitter and then generate stop condition.
So far my attempts failed.
Based on TRM, this is what I do:
if(TimeOut ) {
I2C_DMACmd(I2Cx, DISABLE);
DMA_Cmd(I2Cx_DMA_STREAM_RX, DISABLE);
(void)I2C_ReceiveData(I2Cx);
I2C_AcknowledgeConfig(I2Cx, DISABLE);
I2C_NACKPositionConfig(I2Cx, I2C_NACKPosition_Next);
I2C_GenerateSTOP(I2Cx, ENABLE);
(void)I2C_ReceiveData(I2Cx);
}
How could I achieve my goal?
thank you in advance
