-
有人用过gd32f107库中的串口0 、1、2的串口2吗?
intmain(void){uint16_ti;led_init();systick_config();nvic_irq_enable(USART0_IRQn,0,0);gd_eval_com_init(EVAL_COM0);gd_eval_com_init(EVAL_COM2);usart_interrupt_enable(USART0,USART_INT_RBNE);while(1){}}voidgd_eval_com_init(uint32_tcom){uint32_tcom_id=0U;if(EVAL_COM0==com){com_id=0U;}elseif(EVAL_COM1==com){com_id=1U;}elseif(EVAL_COM2==com){com_id=2U;}/*enableGPIOclock*/rcu_periph_clock_enable(COM_GPIO_CLK[com_id]);/*enableUSARTclock*/rcu_periph_clock_enable(COM_CLK[com_id]);/*connectporttoUSARTx_Tx*/gpio_init(COM_GPIO_PORT[com_id],GPIO_MODE_AF_PP,GPIO_OSPEED_50MHZ,COM_TX_PIN[com_id]);/*connectporttoUSARTx_Rx*/gpio_init(COM_GPIO_PORT[com_id],GPIO_MODE_IN_FLOATING,GPIO_OSPEED_50MHZ,COM_RX_PIN[com_id]);/*USARTconfigure*/usart_deinit(com);usart_baudrate_set(com,9600U);usart_word_length_set(com,USART_WL_8BIT);usart_stop_bit_set(com,USART_STB_1BIT);usart_parity_config(com,USART_PM_NONE);usart_hardware_flow_rts_config(com,USART_RTS_DISABLE);usart_hardware_flow_cts_config(com,USART_CTS_DISABLE);usart_receive_config(com,USART_RECEIVE_ENABLE);usart_transmit_config(com,USART_TRANSMIT_ENABLE);usart_enable(com);}我串口0可以正常收发数据,但是用串口2没有反应
2022-12-07 9