|
这是不能接受数据,复位串口的代码:
USART_InitTypeDef USART_InitStructure;
USART_Cmd(USART1, DISABLE);
DMA_tx_Configuration(1);//发送1个数据的代码
DMA_rx_Configuration(1);//接收数据的复位代码
USART_InitStructure.USART_BaudRate = 57600;
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_Rx | USART_Mode_Tx;
USART_Init(USART1, &USART_InitStructure);
/* Enable USART1 DMA Rx and TX request */
USART_DMACmd(USART1, USART_DMAReq_Rx | USART_DMAReq_Tx, ENABLE);
/* Enable DMA1 Channel4 */
DMA_Cmd(DMA1_Channel4, ENABLE);
/* Enable DMA1 Channel5 */
DMA_Cmd(DMA1_Channel5, ENABLE);
/* Enable the USART1 */
USART_Cmd(USART1, ENABLE);
DMA_ITConfig(DMA1_Channel5, DMA_IT_TC, ENABLE); //使能DMA传输完成中断
DMA_ITConfig(DMA1_Channel4, DMA_IT_TC, ENABLE); //使能DMA传输完成中断 |
|