| 【AT-START-F405测评】串口通讯 · 使用AT32 Work Bench:类似于STM32CubeMX,AT32 Work Bench是一个图形化工具,允许用户选择MCU型号并配置各种外设,包括UART。 · USART配置:在AT32 Work Bench中,选择USART(如USART5),并配置相关的参数,如波特率、数据位、停止位和校验位等。 · 引脚配置:将之前确定的USART管脚(如PB5和PB6)分配给相应的USART通道。 · 时钟配置:确保为UART模块提供了正确的时钟源和频率。   */ int main(void) {   system_clock_config();   at32_board_init();   uart_print_init(115200); 
   /* output a message on hyperterminal using printf function */   printf("AT32F402 405\r\n"); 
   while(1)   {     printf("counter: %u\r\n",time_cnt++);     delay_sec(1);   } } 
 
 
 
 
 void uart_print_init(uint32_t baudrate) {   gpio_init_type gpio_init_struct; 
 #if defined (__GNUC__) && !defined (__clang__)   setvbuf(stdout, NULL, _IONBF, 0); #endif 
   /* enable the uart and gpio clock */   crm_periph_clock_enable(PRINT_UART_CRM_CLK, TRUE);   crm_periph_clock_enable(PRINT_UART_TX_GPIO_CRM_CLK, TRUE); 
   gpio_default_para_init(&gpio_init_struct); 
   /* configure the uart tx pin */   gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;   gpio_init_struct.gpio_out_type  = GPIO_OUTPUT_PUSH_PULL;   gpio_init_struct.gpio_mode = GPIO_MODE_MUX;   gpio_init_struct.gpio_pins = PRINT_UART_TX_PIN;   gpio_init_struct.gpio_pull = GPIO_PULL_NONE;   gpio_init(PRINT_UART_TX_GPIO, &gpio_init_struct); 
   gpio_pin_mux_config(PRINT_UART_TX_GPIO, PRINT_UART_TX_PIN_SOURCE, PRINT_UART_TX_PIN_MUX_NUM); 
   /* configure uart param */   usart_init(PRINT_UART, baudrate, USART_DATA_8BITS, USART_STOP_1_BIT);   usart_transmitter_enable(PRINT_UART, TRUE);   usart_enable(PRINT_UART, TRUE); } 
 |