软硬件完成
所有线都连接完全,
APM32F0xx_SDK解包,
到星空派GD32F303开发板 3 例程Project 4_USART_PrintfMDK-ARM目录打开GD32303E_EVAL.uvprojx厂家示例文件,
编译下载,此板程序。
厂家代码:
- /*!
- file main.c
- brief USART printf demo
- */
- /*
- Copyright (C) 2017 GigaDevice
- 2017-05-19, V1.0.0, demo for GD32F30x
- */
- #include "gd32f30x.h"
- #include "gd32f303e_eval.h"
- #include "systick.h"
- #include
- #include "led.h"
- #include "key.h"
- #include "uart.h"
- void led_init(void);
- void led_flash(int times);
- /*!
- brief main function
- param[in] none
- param[out] none
- retval none
- */
- int main(void)
- {
- /* initialize the LEDs */
- led_init();
-
- /* configure systick */
- systick_config();
-
- /* configure EVAL_COM1 */
- uart0_init();
-
- /* configure TAMPER key */
- key_init();
-
- /* output a message on hyperterminal using printf function */
- printf("rn USART printf example: please press the Tamper key rn");
- uart0_send_string("uart0_send_string rn");
-
- /* wait for completion of USART transmission */
- while(RESET == usart_flag_get(EVAL_COM1, USART_FLAG_TC)){
- }
- while(1){
- /* check if the tamper key is pressed */
- if(RESET == key_state_get()){
- delay_1ms(50);
- if(RESET == key_state_get()){
- delay_1ms(50);
- if(RESET == key_state_get()){
- /* turn on LED2 */
- led_on(1);
- /* output a message on hyperterminal using printf function */
- printf("rn USART printf example rn");
- /* wait for completion of USART transmission */
- while(RESET == usart_flag_get(EVAL_COM1, USART_FLAG_TC)){
- }
- }else{
- /* turn off LED2 */
- led_off(1);
- }
- }else{
- /* turn off LED2 */
- led_off(1);
- }
- }else{
- /* turn off LED2 */
- led_off(1);
- }
- }
- }
- /* 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;
- }
复制代码
编译结果
Build started: Project: GD32303E_EVAL
*** Using Compiler 'V5.06 update 6 (build 750)', folder: 'g:Keil_v5ARMARMCCBin'
Build target 'GD32F303E_EVAL'
compiling main.c...
compiling gd32f30x_it.c...
compiling systick.c...
compiling system_gd32f30x.c...
compiling gd32f30x_adc.c...
compiling gd32f30x_bkp.c...
compiling gd32f30x_can.c...
compiling gd32f30x_crc.c...
compiling gd32f30x_ctc.c...
compiling gd32f30x_dac.c...
compiling gd32f30x_dbg.c...
compiling gd32f30x_dma.c...
compiling gd32f30x_enet.c...
compiling gd32f30x_exmc.c...
compiling gd32f30x_exti.c...
compiling gd32f30x_fmc.c...
compiling gd32f30x_fwdgt.c...
compiling gd32f30x_gpio.c...
compiling gd32f30x_i2c.c...
compiling gd32f30x_misc.c...
compiling gd32f30x_pmu.c...
compiling gd32f30x_rcu.c...
compiling gd32f30x_rtc.c...
compiling gd32f30x_sdio.c...
compiling gd32f30x_spi.c...
compiling gd32f30x_timer.c...
compiling gd32f30x_usart.c...
compiling gd32f30x_wwdgt.c...
compiling gd32f303e_eval.c...
assembling startup_gd32f30x_hd.s...
compiling uart.c...
..bspuartuart.c(68): warning: #550-D: variable "uart0_rcev_buff" was set but never used
static uint8_t uart0_rcev_buff[100];
..bspuartuart.c: 1 warning, 0 errors
compiling key.c...
compiling led.c...
linking...
Program Size: Code=2776 RO-data=336 RW-data=16 ZI-data=1128
FromELF: creating hex file...
".outputProject.axf" - 0 Error(s), 1 Warning(s).
Build Time Elapsed: 00:00:29
debug:
设置下flash
Dll Verison 1.06 Build date: 2019-06-23
Emulaor: LINK, SN: 0023557, Hardware: A, Firmware: 1.23
Manufacturer: , Date: 2020-01-08
Appliaction: LINK, Version: 1.51
Connect Mode SWD, Speed Auto
Out put voltage 3.33V, current 0.00mA, target voltage 3.33V
Found SWD-DP with ID 0x410FC241
TPIU fitted.
ETM fitted.
Found Cortex-M4 , Little endian
FPUnit: 6 code (BP) slots and 2 literal slots
Data Watchpoint: 4
Load "G:\星空派GD32F303开发板\03 例程\Project\04_USART_Printf\MDK-ARM\output\Project.axf"
WS 1, `cksys_freq,0x0A
WS 1, `ahb_freq,0x0A
WS 1, `apb1_freq,0x0A
WS 1, `apb2_freq,0x0A
WS 1, `ck_src,0x0A
WS 1, `ck_freq,0x0A
WS 2, `ahb_exp