问答

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

薛定谔的痞子

TA的家园币:12  

  • GD32F303串口不能产生空闲中断

    初次使用GD32F303芯片,以为没什么难度呢结果一上来就碰到问题了,串口不能产生空闲中断看看我的代码是否有错voidNVIC_swtConfiguration(void){/*USARTinterruptconfiguration*/nvic_irq_enable(MY_USART_IRQ,1,0);usart_interrupt_enable(MY_USART,USART_INT_IDLE);/*enableUSARTTBEinterrupt*/usart_interrupt_enable(MY_USART,USART_INT_RBNE);}//配置通信端口voidfuncSerialConfig(void){///*EnableGPIOclockrcu_periph_clock_enable(MYRCC_USART_PORT);rcu_periph_clock_enable(MYRCC_USART);/*connectporttoUSARTx_Tx*/gpio_init(MY_USART_PORT,GPIO_MODE_AF_PP,GPIO_OSPEED_50MHZ,MY_USART_TX_PIN);/*connectporttoUSARTx_Rx*/gpio_init(MY_USART_PORT,GPIO_MODE_IN_FLOATING,GPIO_OSPEED_50MHZ,MY_USART_RX_PIN);usart_deinit(MY_USART);usart_baudrate_set(MY_USART,115200);usart_receive_config(MY_USART,USART_RECEIVE_ENABLE);usart_transmit_config(MY_USART,USART_TRANSMIT_ENABLE);NVIC_swtConfiguration();usart_enable(MY_USART);waitForSend=1;swt_RxCounter=1;usart_direct_send_data((constuint8_t*)"GD32F303VCT6IDLEINT",21);}中断函数voidUART3_IRQHandler(void){uint16_tRxChar;if((RESET!=usart_interrupt_flag_get(MY_USART,USART_INT_FLAG_RBNE))&&(RESET!=usart_flag_get(MY_USART,USART_FLAG_RBNE))){RxChar=(usart_data_receive(MY_USART)&0xfF);/*receivedata*/#if(ENABEL_DMA_TRANS==0)swt_recArray[swtRecieved][swt_RxCounter++]=RxChar;if(swt_RxCounter>=EP_PACKET_MAX_SIZE){usart_dma_irq_reciev_cb();}#endifusart_flag_clear(MY_USART,USART_FLAG_RBNE);}if((RESET!=usart_flag_get(MY_USART,USART_FLAG_IDLE))&&(RESET!=usart_interrupt_flag_get(MY_USART,USART_INT_IDLE))){RxChar=(usart_data_receive(MY_USART)&0xfF);usart_dma_irq_reciev_cb();}if((RESET!=usart_flag_g

    串口 GD32F303 USART SAR TE se

    2021-06-24 3