cancel
Showing results for 
Search instead for 
Did you mean: 

__HAL_DMA_CLEAR_FLAG: Clear the DMA Stream pending flags.

son1
Associate II
Posted on December 16, 2015 at 04:39

/**

  * @brief  Clear the DMA Stream pending flags.

  * @param  __HANDLE__: DMA handle

  * @param  __FLAG__: specifies the flag to clear.

  *          This parameter can be any combination of the following values:

  *            @arg DMA_FLAG_TCIFx: Transfer complete flag.

  *            @arg DMA_FLAG_HTIFx: Half transfer complete flag.

  *            @arg DMA_FLAG_TEIFx: Transfer error flag.

  *            @arg DMA_FLAG_DMEIFx: Direct mode error flag.

  *            @arg DMA_FLAG_FEIFx: FIFO error flag.

  *         Where x can be 0_4, 1_5, 2_6 or 3_7 to select the DMA Stream flag.   

  * @retval None

  */

#define __HAL_DMA_CLEAR_FLAG(__HANDLE__, __FLAG__) \

(((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA2_Stream3)? (DMA2->HIFCR = (__FLAG__)) :\

 ((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA1_Stream7)? (DMA2->LIFCR = (__FLAG__)) :\

 ((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA1_Stream3)? (DMA1->HIFCR = (__FLAG__)) : (DMA1->LIFCR = (__FLAG__)))

I don't understand how the code from ST HAL can clear the flag?
1 REPLY 1
Posted on December 16, 2015 at 06:47

Read the DMAx_HIFCR/DMAx_LIFCR registers description in the Reference Manual.

The description in the comment may be misleading - it does not clear a pending DMA transfer, it clears the status flags of the DMA stream.

JW