| 
 
| 测试GD32103C-EVAL 串口0 功能,无DMA,板载 GD32F103VCT6 USART0_Tx -->PA9,USART0_Rx -->PA10,
 
 测试结果现象:  1、烧录完后自动运行,出现乱码。
 2、重新按板载复位按键后,正常显示内容。
 3、断电后再上电还是出现乱码。
 讲道理,断电重现上电,也是正常复位,为什么还是会出现乱码。在GD32F305RCT6上测试串口0不会出现这种现象。
 
 求解。。。。。。。
 
 代码如下:
 int main(void)
 {
 /* enable GPIO clock */
 rcu_periph_clock_enable(RCU_GPIOA);
 
 /* enable USART clock */
 rcu_periph_clock_enable(RCU_USART0);
 
 /* connect port to USARTx_Tx */
 gpio_init(GPIOA, GPIO_MODE_AF_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_9);
 
 /* connect port to USARTx_Rx */
 gpio_init(GPIOA, GPIO_MODE_IN_FLOATING, GPIO_OSPEED_50MHZ, GPIO_PIN_10);
 
 /* USART configure */
 usart_deinit(USART0);
 usart_baudrate_set(USART0, 115200U);
 usart_word_length_set(USART0, USART_WL_8BIT);
 usart_stop_bit_set(USART0, USART_STB_1BIT);
 usart_parity_config(USART0, USART_PM_NONE);
 usart_hardware_flow_rts_config(USART0, USART_RTS_DISABLE);
 usart_hardware_flow_cts_config(USART0, USART_CTS_DISABLE);
 usart_receive_config(USART0, USART_RECEIVE_ENABLE);
 usart_transmit_config(USART0, USART_TRANSMIT_ENABLE);
 usart_enable(USART0);
 
 printf("a usart transmit test example!");
 while(1)
 {
 printf("a usart transmit test example!");
 }
 }
 
 /* retarget the C library printf function to the USART */
 int fputc(int ch, FILE *f)
 {
 usart_data_transmit(USART0, (uint8_t)ch);
 while(RESET == usart_flag_get(USART0, USART_FLAG_TBE));
 return ch;
 }
 
 [img][/img]
 | 
 |