//定义DMA映射地址 #define USART2_DR_ADDR 0x40004404; //main函数里面: while (DMA_GetFlagStatus(DMA_FLAG_TC7) == RESET) {//等待发送完全 } //时钟配置加一句: RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA, ENABLE); //串口配置加一句: USART_DMACmd(USART2,USART_DMAReq_Tx,ENABLE); //DMA配置 void DMA_Configuration(void) { DMA_InitTypeDef DMA_InitStructure; DMA_DeInit(DMA_Channel7); //将dma的通道寄存器设为默认值 DMA_InitStructure.DMA_PeripheralBaseAddr = USART2_DR_ADDR; //定义dma外设基地址 DMA_InitStructure.DMA_MemoryBaseAddr = (u32)array_data_send; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST; //外设作为数据传输的目的地 DMA_InitStructure.DMA_BufferSize = 3; //dma缓存大小 DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; //外设地址寄存器不变 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_Circular; //工作在循环缓存模式,数据传输数目为0时,自动恢复配置初值 DMA_InitStructure.DMA_Priority = DMA_Priority_High; DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; //通道未被设置成内存到内存模式,与循环模式相对 DMA_Init(DMA_Channel7, &DMA_InitStructure); //将DMA_InitStructure中指定的参数初始化dma的通道寄存器 DMA_Cmd(DMA_Channel7, ENABLE); //使能通道 }