| 
 
| 情况如下: 1 第一次调用USART1_SendDMA时无法进入中断,但后续却可以;
 2 没有输出
 代码如下:
 串口配置:
 RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA,ENABLE);
 RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1,ENABLE);
 RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA1 , ENABLE);
 
 DMA_DeInit(DMA1_Stream0);
 GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_USART1);
 GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_USART1);
 
 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;//
 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
 GPIO_Init(GPIOA, &GPIO_InitStructure);
 
 GPIO_InitStructure.GPIO_Pin =GPIO_Pin_10;//  GPIO_PinSource10;
 GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
 GPIO_Init(GPIOA, &GPIO_InitStructure);
 
 USART_InitStructure.USART_BaudRate = 115200;
 USART_InitStructure.USART_WordLength = USART_WordLength_8b;
 USART_InitStructure.USART_StopBits = USART_StopBits_1;
 USART_InitStructure.USART_Parity = USART_Parity_No;
 
 USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
 USART_InitStructure.USART_Mode = USART_Mode_Tx;
 USART_Init(USART1, &USART_InitStructure);
 
 NVIC_PriorityGroupConfig(NVIC_PriorityGroup_3);
 NVIC_InitStructure.NVIC_IRQChannel = DMA1_Stream0_IRQn;
 NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
 NVIC_Init(&NVIC_InitStructure);
 DMA_ITConfig(DMA1_Stream0,DMA_IT_TC,ENABLE);
 USART_DMACmd(USART1, USART_DMAReq_Tx, ENABLE);
 
 USART_Cmd(USART1, ENABLE);
 输出函数:
 void USART1_SendDMA(char* buf,int len)
 {
 DMA_InitTypeDef DMA_InitStruct;
 DMA_Cmd(DMA1_Stream0,DISABLE);
 DMA_ClearITPendingBit(DMA1_Stream0, DMA_IT_TCIF0);
 
 DMA_InitStruct.DMA_Channel = DMA_Channel_0;
 DMA_InitStruct.DMA_PeripheralBaseAddr = (uint32_t)(&USART1->DR);
 DMA_InitStruct.DMA_Memory0BaseAddr = (uint32_t)buf;
 DMA_InitStruct.DMA_DIR = DMA_DIR_MemoryToPeripheral;
 DMA_InitStruct.DMA_BufferSize = len;
 DMA_InitStruct.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
 DMA_InitStruct.DMA_MemoryInc = DMA_MemoryInc_Enable;
 DMA_InitStruct.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
 DMA_InitStruct.DMA_MemoryDataSize = DMA_PeripheralDataSize_Byte;
 DMA_InitStruct.DMA_Mode = DMA_Mode_Normal;
 DMA_InitStruct.DMA_Priority = DMA_Priority_Medium;
 DMA_InitStruct.DMA_FIFOMode = DMA_FIFOMode_Disable;
 DMA_InitStruct.DMA_MemoryBurst = DMA_MemoryBurst_Single;
 DMA_InitStruct.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
 DMA_InitStruct.DMA_FIFOThreshold = DMA_FIFOThreshold_1QuarterFull;
 DMA_Init(DMA1_Stream0,&DMA_InitStruct);
 
 DMA_Cmd(DMA1_Stream0,ENABLE);
 中断:
 void DMA1_Stream0_IRQHandler()
 {
 if(DMA_GetITStatus(DMA1_Stream0, DMA_IT_TCIF0))
 {
 //TODO:Add code here
 DMA_ClearITPendingBit(DMA1_Stream0, DMA_IT_TCIF0);
 DMA_Cmd(DMA1_Stream0,DISABLE);
 }
 }
 DEBUG时候发现USART1_SendDMA输入的buf内容正确,比如输入一个"TEST",可以在DEBUG时候看到buf里面对应的内容,len此时为4
 | 
 |