【GMT43智能液晶模块】例程十:DMA实验——存储器到存储器的传输
实验原理:
DMA(直接存储器访问)传输不需要占用CPU,可以在存储器至存储器实现高速的数据
传输。本实验采用DMA2控制器的数据流0,选用通道0进行数据传输。通过液晶控制传输
和结果显示。
示例截图:
源代码下载链接:
链接:https://pan.baidu.com/s/1miXeWVe 密码:tmrq
GMT43购买链接:
核心代码:
static void frame_process(void) { DMA_InitTypeDef DMA_InitStructure; GUI_CURSOR_Show(); WM_SetCreateFlags(WM_CF_MEMDEV); GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0); DMA_InitStructure.DMA_Channel = DMA_Channel_0; DMA_InitStructure.DMA_PeripheralBaseAddr = (unsigned long int)src_buffer; DMA_InitStructure.DMA_Memory0BaseAddr = (unsigned long int)dst_buffer; DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToMemory; DMA_InitStructure.DMA_BufferSize = (unsigned long int)BUFFER_SIZE; DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Enable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Word; DMA_InitStructure.DMA_Mode = DMA_Mode_Normal; DMA_InitStructure.DMA_Priority = DMA_Priority_High; DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable; DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full; DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; DMA_Init(DMA2_Stream0, &DMA_InitStructure); while(1){ GUI_Exec(); } }