English
Language : 

AN3117 Datasheet, PDF (22/28 Pages) STMicroelectronics – This application note describes how to use the direct memory access
DMA programming examples
AN3117
4.4.2
DMA transfer example in Wait for interrupt (WFI) mode
This example uses the DMA peripheral to transfer data in exactly the same way as the WFE
example. The difference is that the treatment (LED activation/deactivation depending on the
data in the RAM buffer) is performed by the DMA transfer complete interrupt routine, without
returning to the main program.
The code for this example is provided in the STM8L05x/STM8L15x/STM8L16x/STM8AL31x/
STM8AL3Lx standard peripheral library package.
4.5
DMA transfer example with TIM1 in Burst mode
Figure 7. DMA transfer example with TIM1 in Burst mode
DMA
source
Data CR1
Data CR2
Data SMCR
Data ETR
Program bus
System
bus
DMA1 bus
DMA1
Channel 2
TIM1
Data OISR
DMA
destination
TIM1_DMAR
TIM1_CR1
TIM1_CR2
TIM1_SMCR
TIM1_ETR
...
TIM1_OISR
ai17422
This example uses the DMA peripheral in Burst mode to transfer data from the RAM
memory to TIM1. TIM1 is configured in pulse width modulation (PWM) output mode and
DMA channel 2 is configured to transfer data from the RAM memory to the TIM1 registers
(TIM1_PSCRH, TIM1_PSCRL, TIM1_ARRH, TIM1_ARRL, TIM1_RCR, TIM1_CCR1H,
TIM1_CCR1L). The goal of this data transfer is to update simultaneously TIM1 channel 1
frequency and duty cycle when an EXTI event triggered by the key button occurs.
The code for this example is provided in the STM8L05x/STM8L15x/STM8L16x/STM8AL31x/
STM8AL3Lx standard peripheral library package.
22/28
Doc ID 16846 Rev 4