9.2.3 Data Counter functions
This subsection provides function allowing to configure and read the buffer size (number of
data to be transferred).The DMA data counter can be written only when the DMA channel
is disabled (ie. after transfer complete event).
The following function can be used to write the Channel data counter value:
ï‚· void DMA_SetCurrDataCounter(DMA_Channel_TypeDef* DMAy_Channelx, uint16_t
DataNumber).
It is advised to use this function rather than DMA_Init() in situations where only
the Data buffer needs to be reloaded.
The DMA data counter can be read to indicate the number of remaining transfers for the
relative DMA channel. This counter is decremented at the end of each data transfer and
when the transfer is complete:
ï‚· If Normal mode is selected: the counter is set to 0.
ï‚· If Circular mode is selected: the counter is reloaded with the initial value(configured
before enabling the DMA channel).
The following function can be used to read the Channel data counter value:
ï‚· uint16_t DMA_GetCurrDataCounter(DMA_Channel_TypeDef* DMAy_Channelx).
ï‚· DMA_SetCurrDataCounter()
ï‚· DMA_GetCurrDataCounter()
9.2.4 Interrupts and flags management functions
This subsection provides functions allowing to configure the DMA Interrupt sources and
check or clear the flags or pending bits status. The user should identify which mode will be
used in his application to manage the DMA controller events: Polling mode or Interrupt
mode.
Polling Mode
Each DMA channel can be managed through 4 event Flags (y : DMA Controller number, x
: DMA channel number):
1. DMAy_FLAG_TCx : to indicate that a Transfer Complete event occurred.
2. DMAy_FLAG_HTx : to indicate that a Half-Transfer Complete event occurred.
3. DMAy_FLAG_TEx : to indicate that a Transfer Error occurred.
4. DMAy_FLAG_GLx : to indicate that at least one of the events described above
occurred.
Clearing DMAy_FLAG_GLx results in clearing all other pending flags of the same
channel (DMAy_FLAG_TCx, DMAy_FLAG_HTx and DMAy_FLAG_TEx).
In this Mode it is advised to use the following functions:
ï‚· FlagStatus DMA_GetFlagStatus(uint32_t DMA_FLAG);