實驗原理:
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(); } }