1.进入空闲中断后,先关闭DMA
2.读取数据长度,
3.重新设置重新设置DMA传输数据数量
4.开启DMA
if(USART_GetITStatus(USART6, USART_IT_IDLE) != RESET)//如果为空闲总线中断
{
USART_ReceiveData(USART6);
USART_ClearITPendingBit(USART6, USART_IT_IDLE);
DMA_Cmd(DMA2_Stream2, DISABLE);//关闭DMA,防止处理其间有数据
usart6_dma_receive_len = USART6_DMA_RCE_MAX_LENGHT - DMA_GetCurrDataCounter(DMA2_Stream2); //数据长度
usart6_dma_receive_flg = 0x01;
DMA_SetCurrDataCounter(DMA2_Stream2, USART6_DMA_RCE_MAX_LENGHT); //重新设置DMA传输数据数量
DMA_Cmd(DMA2_Stream2, ENABLE);//开启DMA
}
1.进入空闲中断后,先关闭DMA
2.读取数据长度,
3.重新设置重新设置DMA传输数据数量
4.开启DMA
if(USART_GetITStatus(USART6, USART_IT_IDLE) != RESET)//如果为空闲总线中断
{
USART_ReceiveData(USART6);
USART_ClearITPendingBit(USART6, USART_IT_IDLE);
DMA_Cmd(DMA2_Stream2, DISABLE);//关闭DMA,防止处理其间有数据
usart6_dma_receive_len = USART6_DMA_RCE_MAX_LENGHT - DMA_GetCurrDataCounter(DMA2_Stream2); //数据长度
usart6_dma_receive_flg = 0x01;
DMA_SetCurrDataCounter(DMA2_Stream2, USART6_DMA_RCE_MAX_LENGHT); //重新设置DMA传输数据数量
DMA_Cmd(DMA2_Stream2, ENABLE);//开启DMA
}
举报