问答

汇集网友智慧,解决技术难题

花火122345

TA的家园币:25  

  • GD32F470 串口3无法进入中断

    voidUART3_Init(){/*enableGPIOclock*/rcu_periph_clock_enable(RCU_GPIOC);/*enableUSARTclock*/rcu_periph_clock_enable(RCU_UART3);/*configuretheUSART0TXpinandUSART0RXpin*/gpio_af_set(GPIOC,GPIO_AF_8,GPIO_PIN_11);gpio_af_set(GPIOC,GPIO_AF_8,GPIO_PIN_10);/*configureUART4TXasalternatefunctionpush-pull*/gpio_mode_set(GPIOC,GPIO_MODE_AF,GPIO_PUPD_PULLUP,GPIO_PIN_10);gpio_output_options_set(GPIOC,GPIO_OTYPE_PP,GPIO_OSPEED_50MHZ,GPIO_PIN_10);/*configureUSART0RXsalternatefionpush-pull*/gpio_mode_set(GPIOC,GPIO_MODE_AF,GPIO_PUPD_PULLDOWN,GPIO_PIN_11);//gpio_output_options_set(GPIOC,GPIO_OTYPE_PP,GPIO_OSPEED_50MHZ,GPIO_PIN_11);/*USARTconfigure*/usart_deinit(UART3);usart_baudrate_set(UART3,115200U);usart_receive_config(UART3,USART_RECEIVE_ENABLE);usart_transmit_config(UART3,USART_TRANSMIT_ENABLE);usart_enable(UART3);nvic_irq_enable(UART3_IRQn,0,1);/*enableUSARTTBEinterrupt*/usart_interrupt_enable(UART3_IRQn,USART_INT_TBE);usart_interrupt_enable(UART3_IRQn,USART_INT_RBNE);usart_interrupt_enable(UART3_IRQn,USART_INT_IDLE);}voidUART3_IRQHandler(void){if((RESET!=usart_interrupt_flag_get(UART3,USART_INT_FLAG_RBNE))&&(RESET!=usart_flag_get(UART3,USART_FLAG_RBNE))){/*receivedata*/USART_Receive_Data[0]=usart_data_receive(UART3);}if((RESET!=usart_interrupt_flag_get(UART3,USART_INT_FLAG_IDLE))&&(RESET!=usart_flag_get(UART3,USART_FLAG_IDLE))){/*receivedata*/usart_interrupt_flag_clear(UART3,USART_INT_FLAG_IDLE);}}这样配置无法进入中断,是什么原因?

    GD32F470

    2023-12-20 0