CH32V307 串口空閑中斷USART_IT_IDLE不觸發(fā)
void?USARTx_Init(USART_TypeDef?*USARTx,?uint32_t?baudrate)
{
????USART_InitTypeDef?USART_InitStructure?=?{0};

????USART_InitStructure.USART_BaudRate?=?baudrate;
????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_Mode_Rx;
????USART_Init(USARTx,?&USART_InitStructure);

????USART_ITConfig(USARTx,?USART_IT_IDLE,?ENABLE);
????USART_ClearFlag(USARTx,?USART_IT_IDLE);
????USART_Cmd(USARTx,?ENABLE);
}

void?USART2_IRQHandler(void)
{
????if(USART_GetITStatus(USART2,?USART_IT_IDLE)?!=?RESET)
????{
????????com2_info.rx_flag?=?1;
????????com2_info.rx_len?=?com2_info.rx_max?-?DMA_GetCurrDataCounter(DMA1_Channel6);
????????DMA_Cmd(DMA1_Channel6,?DISABLE);\
????????USART_ClearFlag(USART2,?USART_IT_IDLE);
????}
}

使能了空閑中斷,可是不進(jìn)串口中斷


原來(lái)沒(méi)開(kāi)啟中斷

? ? NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;

? ? NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;

? ? NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;

? ? NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

? ? NVIC_Init(&NVIC_InitStructure);



只有登錄才能回復(fù),可以選擇微信賬號(hào)登錄

国产91精品新入口,国产成人综合网在线播放,九热这里只有精品,本道在线观看,美女视频a美女视频,韩国美女激情视频,日本美女pvp视频