Professional Documents
Culture Documents
Chap08 STM32F1 DMA
Chap08 STM32F1 DMA
Chap08 STM32F1 DMA
Controller
2
1 Brid
ge
Data bus Peripheral Bus
Mov Data[i] , Ri
Each Transfer Instruction involves 2 Bus Access from processor (Read + Write) :Time
consuming instructions.
The SPP Data Transfers are ensured by the DMAC : Direct Memort Access Controller
Bridge
Data Bus (with Access Arbitration) Peripheral Bus
DMAC Strcuture
• A DMAC is a Control Peripheral containing
DMA
registers that can ba accessed by the processor.
Channel N
• A DMAC manages many channels.
Channel.
Transfer Requests
From Peripherals to
Channel. • Each Channel accepts Transfer Requests from a
channels Channel 1
limited number of peripherals
@source
@destination
• When active, a Channel ensures a transfer from a
Processor Taille source to a destination. The registers contents
Etat transfert
indicate:
Buffer
- Source Address.
Reg Config Arbitrage - Destination Address.
Bus
- Data Size to be transfered.
Data Bus (with Arbitration) - etc ……
Data Transfer with DMAC
all the processor should do is to configure the DMAC Channels (Src, Dest, Size, etc …)
Code
Bus @src Periph
@dest
Taille
Bridge
Data Bus (with Arbitration) Peripheral Bus
Peripheral
memory
STM32F1 : DMAC Registers
DMAC Channel Configuration
DMA_InitTypedef DMA_InitStructure;
DMA_InitStructure.
DMA_InitStructure.
DMA_InitStructure.
DMAC Channel Configuration
DMA_InitStructure.
DMA_InitStructure.
DMA_InitStructure.
DMA_InitStructure.
DMA_InitStructure.
DMA_InitStructure.
DMA_InitStructure.
DMA_InitStructure.
DMAC Channel Configuration
DMAC Channel Configuration
DMAC Channel Configuration
DMAC Channel Configuration
DMAC Channel Configuration
DMA Interrupts
DMAC Register Addresses
Canal x 1 2 3 4 5 6 7
Offset d’un canal x : 0x08 + (x-1)*0x14
Offset 0x08 0x1C 0x30 0x44 0x58 0x6C 0x80
Adresse du registre d’un canal x du DMAy = Adr de base du DMAy + offset canal x + offset du registre
Periph
Data
(Src)
Memory
(Dest)
Data from peripheral must be transfered from peripheral to Memory and processed (N Bytes) by the
Cortex-M3.
processor
Memory
TC TC
DMA (Dest) TC
Periph
Utilisation optimale des ressources du processeur Data
(Src)
1 2 1 2 1 2
processor
Memory
HT HT HT HT
TC 1
TC TC
DMA 2 1 2
2
1 1 2
TC
Example:
RxBuffer[N]=‘’………………….’’;
TxBuffer[N]=‘’………………….’’;
HAL_DMA_Start (&hdma_memtomem_dma1_channely, TxBuffer, RxBuffer, 20); //y : can be 1 to 7
DMAC HAL Functions (Mem / Periph)
Start DMA Transfer :The periph PPP
HAL_StatusTypeDef HAL_PPP_Receive_DMA (PPP_HandleTypeDef *hppp, generates a Transfer Request when
it receives Data.
uint8_t *pData , uint16_t Size) Interrupts are enabled