CH32V307 串口空闲中断USART_IT_IDLE不触发
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);
    }
}

使能了空闲中断,可是不进串口中断


原来没开启中断

    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);



只有登录才能回复,可以选择微信账号登录