AnsweredAssumed Answered

I2C DMA Address Ack Failure

Question asked by khanna.advitya.001 on Oct 22, 2015
Latest reply on Nov 6, 2015 by Ricy
Dear All,

I am making calls to the HAL_I2C_Mem_Read_DMA, HAL_I2C_Mem_Write_DMA provided by the STM32HAL driver, and in some cases expecting a Address ACK failure. It seems that the implementation of these functions involves a call first to the HAL_DMA_START_IT, which enables the DMA stream, and then proceeds to send the slave address/ memory address. However, since I expect there to be an Address ACK failure (I am trying to find multiple devices out of which only some of them will be discovered), the DMA transfer is started before the slave/ memory address is sent over, and we are constantly waiting for the DMA transfer to complete. If I swap the order-- the Slave and Memory Address is sent before the DMA transfer has been started up-- then everything works as expected. That is, I get a HAL_I2C_ERROR_AF and the DMA transfer has not been started because the call to HAL_I2C_Mem_Read_DMA has returned HAL_ERROR.

Firstly, is there a reason for the current ordering scheme of starting the DMA transfer for I2C peripheral before the sending of the slave and memory address? And, if that is so, would it be possible to somehow disable the stream (without completing the currently scheduled DMA transfer because I have tried to HAL_DMA_DeInit and HAL_DMA_Abort and they wait for the current transfer to complete before disabling the stream) and cleanly handle the Address ACK failure.