AG32VF407 AGRV2K 串口printf调试输出

视频讲解

[AG32VF407]国产MCU+FPGA 串口printf调试输出及演示

原理图

AG32VF407 AGRV2K 串口printf调试输出_第1张图片

测试代码

新建一个platformio工程,复制如下文件到测试工程目录下
E:\tech\AGM-AG32VF\sdk-release\AgRV_pio\platforms\AgRV\boards\agrv2k_407\board.asf
E:\tech\AGM-AG32VF\sdk-release\AgRV_pio\platforms\AgRV\boards\agrv2k_407\board.ve
E:\tech\AGM-AG32VF\sdk-release\AgRV_pio\platforms\AgRV\examples\example\platformio.iniAG32VF407 AGRV2K 串口printf调试输出_第2张图片
platformio.ini中增加如下配置,uart调试端口可以查看设备管理器,COM多少,其中速率默认sdk为500000AG32VF407 AGRV2K 串口printf调试输出_第3张图片新建src目录,创建uart.c文件,代码如下:

#include "board.h"

int main(void)
{
    board_init();
    int cnt=0;
    #define LED_D3_GPIO GPIO4
    #define LED_D3_GPIO_BITS (1 << 3)
    SYS_EnableAPBClock(APB_MASK_GPIO4);
    GPIO_SetOutput(LED_D3_GPIO, LED_D3_GPIO_BITS);
    GPIO_SetHigh(LED_D3_GPIO, LED_D3_GPIO_BITS);
    int counter = 0;
    while (1) {
        UTIL_IdleMs(500);
        GPIO_Toggle(LED_D3_GPIO, LED_D3_GPIO_BITS);
        printf("test %d\r\n", cnt++);
    }
}

build,upload,然后再点击Serial Monitor,输出如下图AG32VF407 AGRV2K 串口printf调试输出_第4张图片

printf实现

E:\tech\AGM-AG32VF\sdk-release\AgRV_pio\packages\framework-agrv_sdk\misc\syscalls.c
    int printf(const char* fmt, ...)
          int ret = vprintfmt((void*)putchar, 0, fmt, ap, 0);
E:\tech\AGM-AG32VF\sdk-release\AgRV_pio\packages\framework-agrv_sdk\src\util.c
    int putchar(int ch)
        UART_SendCh(UARTx(LOGGER_UART), ch);
E:\tech\AGM-AG32VF\sdk-release\AgRV_pio\platforms\AgRV\boards\agrv2k_407\board.c
    void board_init(void)
        MSG_UART = UARTx(LOGGER_UART);

你可能感兴趣的:(fpga,fpga开发)