问答

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

TZK123

TA的家园币:10  

  • GD32E103VB Uart0

    为什么我用的GD32E103VB的Uart打印出来是乱码。。。代码如下:#include"gd32e10x.h"#include"gd32e103v_eval.h"#include"systick.h"#include/*retargettheClibraryprintffunctiontotheUSART*/intfputc(intch,FILE*f){usart_data_transmit(USART0,(uint8_t)ch);while(RESET==usart_flag_get(USART0,USART_FLAG_TBE));returnch;}voiduart_init(void){rcu_periph_clock_enable(RCU_AF);/*enableGPIOclock*/rcu_periph_clock_enable(RCU_GPIOA);//gpio_pin_remap_config(GPIO_USART0_REMAP,ENABLE);/*enableUSARTclock*/rcu_periph_clock_enable(RCU_USART0);/*connectporttoUSARTx_Tx*/gpio_init(GPIOA,GPIO_MODE_AF_PP,GPIO_OSPEED_50MHZ,GPIO_PIN_9);/*connectporttoUSARTx_Rx*/gpio_init(GPIOA,GPIO_MODE_IN_FLOATING,GPIO_OSPEED_50MHZ,GPIO_PIN_10);//gpio_pin_remap_config(GPIO_USART0_REMAP,ENABLE);/*USARTconfigure*/usart_deinit(USART0);usart_baudrate_set(USART0,115200U);usart_receive_config(USART0,USART_RECEIVE_ENABLE);usart_transmit_config(USART0,USART_TRANSMIT_ENABLE);usart_enable(USART0);}intmain(void){systick_config();uart_init();while(1){printf("helloworld\n");}}打印结果如下:l"l"Xl"H$ll"l"XlDl"l。。。。。。

    UART0 SAR USART pi IO GPIO

    2021-04-27 0