-
GD32F150C8T6配置USART1不成功
#defineEVAL_COM1USART1#defineEVAL_COM1_CLKRCU_USART1#defineEVAL_COM1_TX_PINGPIO_PIN_2//PA2#defineEVAL_COM1_RX_PINGPIO_PIN_3//PA3#defineEVAL_COM_GPIO_PORTGPIOA#defineEVAL_COM_GPIO_CLKRCU_GPIOA#defineEVAL_COM_AFGPIO_AF_1voidgd_eval_com_init(uint32_tCOM){uint32_tCOM_ID=0U;if(EVAL_COM1==COM){COM_ID=0U;}rcu_periph_clock_enable(RCU_GPIOA);//USART时钟使能rcu_periph_clock_enable(RCU_USART1);//配置TX为推挽复用模式gpio_mode_set(GPIOA,GPIO_MODE_AF,GPIO_PUPD_PULLUP,GPIO_PIN_2);gpio_output_options_set(EVAL_COM_GPIO_PORT,GPIO_OTYPE_PP,GPIO_OSPEED_10MHZ,GPIO_PIN_2);//配置RX为浮空输入模式gpio_mode_set(GPIOA,GPIO_MODE_AF,GPIO_PUPD_PULLUP,GPIO_PIN_3);gpio_output_options_set(EVAL_COM_GPIO_PORT,GPIO_OTYPE_PP,GPIO_OSPEED_10MHZ,GPIO_PIN_3);usart_deinit(USART1);usart_baudrate_set(USART1,9600U);//波特率usart_word_length_set(USART1,USART_WL_8BIT);//帧数据字长usart_stop_bit_set(USART1,USART_STB_1BIT);//停止位usart_parity_config(USART1,USART_PM_NONE);//奇偶校验位usart_hardware_flow_rts_config(USART1,USART_RTS_DISABLE);//硬件流控制RTSusart_hardware_flow_cts_config(USART1,USART_CTS_DISABLE);//硬件流控制CTSusart_receive_config(USART1,USART_RECEIVE_ENABLE);//使能接收usart_transmit_config(USART1,USART_TRANSMIT_ENABLE);//使能发送usart_enable(USART1);nvic_irq_enable(USART1_IRQn,0,1);//使能串口接收中断usart_interrupt_enable(USART1,USART_INT_RBNE);usart_interrupt_enable(USART1,USART_INT_TBE);}voidUSART0_IRQHandler(void){if(RESET!=usart_interrupt_flag_get(EVAL_COM1,USART_INT_FLAG_RBNE)){/*receivedata*/receiver_buffer[rxcount++]=usart_data_receive(EVAL_COM1);if(rxcount==receivesize){//usart_interrupt_disable(EV
2022-08-11 4