Theoretical part
Functional Block Diagram
About
DMA: Data Memory Access, direct memory access.
The main function of the data can be moved from one place to another place , and do not take up CPU. Temporary data without CPU
DMA1: seven channels, may be implemented P-> M, M-> P, M-> M
DMA2: There are seven channels, may be implemented P-> M, M-> P, M-> M
M: P Memery: Peripheral
the P-> M: the ADC
DMA function block diagram of a
1-DMA request
2- passage
3- arbiter
arbiter
a plurality of DMA requests together, how to do?
1, the software stage, DMA_CCRx: PL [1: 0 ]. 00/01/10/11
2, hardware stages, the channel number priority small large, DMl priority higher than the priority of the DMA2.
Firmware library functions
DMA structure:
typedef struct
{
//数据从哪里来,到哪里去
uint32_t DMA_PeripheralBaseAddr; /*!<外设地址 Specifies the peripheral base address for DMAy Channelx. */
uint32_t DMA_MemoryBaseAddr; /*!<存储器地址 Specifies the memory base address for DMAy Channelx. */
uint32_t DMA_DIR; /*!<传输方向 Specifies if the peripheral is the source or destination.
This parameter can be a value of @ref DMA_data_transfer_direction */
//传多少数据
uint32_t DMA_BufferSize; /*!<传输数目 Specifies the buffer size, in data unit, of the specified Channel.
The data unit is equal to the configuration set in DMA_PeripheralDataSize
or DMA_MemoryDataSize members depending in the transfer direction. */
uint32_t DMA_PeripheralInc; /*!<外设地址是否递增 Specifies whether the Peripheral address register is incremented or not.
This parameter can be a value of @ref DMA_peripheral_incremented_mode */
uint32_t DMA_MemoryInc; /*!<存储器地址是否递增 Specifies whether the memory address register is incremented or not.
This parameter can be a value of @ref DMA_memory_incremented_mode */
uint32_t DMA_PeripheralDataSize; /*!<外设数据宽度 Specifies the Peripheral data width.
This parameter can be a value of @ref DMA_peripheral_data_size */
uint32_t DMA_MemoryDataSize; /*!<存储器数据宽度 Specifies the Memory data width.
This parameter can be a value of @ref DMA_memory_data_size */
//什么时候结束
uint32_t DMA_Mode; /*!<模式选择 Specifies the operation mode of the DMAy Channelx.
This parameter can be a value of @ref DMA_circular_normal_mode.
@note: The circular buffer mode cannot be used if the memory-to-memory
data transfer is configured on the selected Channel */
uint32_t DMA_Priority; /*!<通道优先级 Specifies the software priority for the DMAy Channelx.
This parameter can be a value of @ref DMA_priority_level */
//memory to memory
uint32_t DMA_M2M; /*!<存储器到存储器模式 Specifies if the DMAy Channelx will be used in memory-to-memory transfer.
This parameter can be a value of @ref DMA_memory_to_memory */
}DMA_InitTypeDef;
Firmware library functions
void DMA_DeInit(DMA_Channel_TypeDef* DMAy_Channelx);
void DMA_Init(DMA_Channel_TypeDef* DMAy_Channelx, DMA_InitTypeDef* DMA_InitStruct);
void DMA_StructInit(DMA_InitTypeDef* DMA_InitStruct);
void DMA_Cmd(DMA_Channel_TypeDef* DMAy_Channelx, FunctionalState NewState);
void DMA_ITConfig(DMA_Channel_TypeDef* DMAy_Channelx, uint32_t DMA_IT, FunctionalState NewState);
void DMA_SetCurrDataCounter(DMA_Channel_TypeDef* DMAy_Channelx, uint16_t DataNumber);
uint16_t DMA_GetCurrDataCounter(DMA_Channel_TypeDef* DMAy_Channelx);
FlagStatus DMA_GetFlagStatus(uint32_t DMAy_FLAG);
void DMA_ClearFlag(uint32_t DMAy_FLAG);
ITStatus DMA_GetITStatus(uint32_t DMAy_IT);
void DMA_ClearITPendingBit(uint32_t DMAy_IT);
* The next section to start programming.