执行下面的代码后,DMA1_Channel2会循环将Send_Buf1的数据发送出去。发送过程中,如果调用USART_DMACmd(USART1, USART_DMAReq_Tx, DISABLE); 这时DMA1_Channel2会停止发送数据(假如这时正在发送Send_Buf1[300])。这时,调用USART_DMACmd(USART1, USART_DMAReq_Tx, ENABLE);,DMA1_Channel2会从Send_Buf1[301]开始发送数据。 问题:我想在接下去调用USART_DMACmd(USART1, USART_DMAReq_Tx, ENABLE); 时,从Send_Buf1[0]开始发送,我该如何做? unsigned char Send_Buf1[1000] = {0}; DMA_InitTypeDef DMA_InitStructure; //DMA_Cmd(DMA1_Channel2, DISABLE); DMA_DeInit(DMA1_Channel2); DMA_InitStructure.DMA_BufferSize = SENDBUF_SIZE_USART1; DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; //DMA_InitStructure.DMA_Mode = DMA_Mode_Normal; DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)Send_Buf1; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST; DMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh; DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&(USART1->TDR); DMA_Init(DMA1_Channel2, &DMA_InitStructure); DMA_Cmd(DMA1_Channel2, DISABLE); DMA_Cmd(DMA1_Channel2, ENABLE); |
USART_DMACmd(USART1, USART_DMAReq_Tx,ENABLE);
USART_DMACmd(USART1, USART_DMAReq_Rx, ENABLE);
USART_ITConfig(USART1,USART_IT_IDLE,ENABLE);
看看这个帖子参考下
http://blog.csdn.net/jutun5887/article/details/78652367
评分
查看全部评分