3595 views|0 replies

98

Posts

0

Resources
The OP
 

[GD32F350 Development Sharing 6] Dual Serial Port Application of USART0 and USART1 [Copy link]

As shown in the figure, GD32F350 has two serial ports, USART0 and USART1. You can refer to the manual for details on which pins are multiplexed into the serial ports. My GPIO multiplexing configuration is as follows
The serial port initialization function is
  1. void gd_eval_com_init(uint32_t com) { uint32_t COM_ID; if(EVAL_COM1 == com){ COM_ID = 0U; }else{ COM_ID = 1U; } /* enable COM GPIO clock */ rcu_periph_clock_enable(EVAL_COM_GPIO_CLK); /* enable USART clock */ rcu_periph_clock_enable(COM_CLK[COM_ID]); /* connect port to USARTx_Tx */ gpio_af_set(EVAL_COM_GPIO_PORT, EVAL_COM_AF, COM_TX_PIN[COM_ID]); /* connect port to USARTx_Rx */ gpio_af_set(EVAL_COM_GPIO_PORT, EVAL_COM_AF, COM_RX_PIN[COM_ID]); /* configure USART Tx as alternate function push-pull */ gpio_mode_set(EVAL_COM_GPIO_PORT, GPIO_MODE_AF, GPIO_PUPD_PULLUP, COM_TX_PIN[COM_ID]); gpio_output_options_set(EVAL_COM_GPIO_PORT, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, COM_TX_PIN[COM_ID]); /* configure USART Rx as alternate function push-pull */ gpio_mode_set(EVAL_COM_GPIO_PORT, GPIO_MODE_AF, GPIO_PUPD_PULLUP, COM_RX_PIN[COM_ID]); gpio_output_options_set(EVAL_COM_GPIO_PORT, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, COM_RX_PIN[COM_ID]); /* USART configure */ usart_deinit(com); usart_baudrate_set(com, 115200U); usart_receive_config(com, USART_RECEIVE_ENABLE); usart_transmit_config(com, USART_TRANSMIT_ENABLE); usart_enable(com); }
复制代码
Serial port sending function, serial port 0 as an example [code]void USART_SendBuffer(uint8_t *buf, uint16_t Size) { uint16_t len=0; for (len=0;len
[GD32F350 Development Sharing 6] Dual Serial Port Application of USART0 and USART1


This post is from GD32 MCU
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list