gpt4 book ai didi

无法使用 printf 命令构建 atmel studio 6.2 项目

转载 作者:行者123 更新时间:2023-11-30 15:16:23 26 4
gpt4 key购买 nike

我是 Atmel Studio 的新手。我使用 ATSAMV71Q21 器件创建了新的 GCC C 执行项目。在 main.c 文件中添加 printf 然后运行 ​​build 并得到一堆“ undefined reference (_write、_fsta 等)错误。我尝试了 Atmel“入门”示例,它工作正常。我该如何解决这个问题?下面是代码和错误消息。感谢您的帮助。

#include "sam.h"
#include <stdio.h>
#include <stdbool.h>

int main(void)
{
/* Initialize the SAM system */
SystemInit();

while (1)
{
printf("abc");
//TODO:: Please write your application code
}
}

d:/atmel/atmel toolchain/arm gcc/native/4.8.1443/arm-gnu-toolchain/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/lib/armv7e-m\libc.a(lib_a-sbrkr.o): In function '_sbrk_r': D:\Atmel\samv71_softpack_1.4_for_astudio_6_2\studio\Atmel\samv71_Xplained_Ultra\examples\test\test\Debug\sbrkr.c(1,1): error: undefined reference to '_sbrk'

最佳答案

我还不知道如何使用简单的 C 程序(#include "sam.h")来完成您想要的操作,但如果您愿意,我可以帮助您使用 ASF API。

您必须首先生成一个 C-ASF 项目。然后,您可以使用 ASF 向导将标准串行 I/O 添加到您的项目中。正确配置,printf、puts...将打印到连接到 Controller 的终端程序。

#include <asf.h>
#include "stdio_serial.h"

static void configure_console(void)
{
const usart_serial_options_t uart_serial_options = {
.baudrate = CONF_UART_BAUDRATE,
.paritytype = CONF_UART_PARIT
};

/* Configure console UART. */
sysclk_enable_peripheral_clock(CONSOLE_UART_ID);
stdio_serial_init(CONF_UART, &uart_serial_options);
}

int main(void)
{
/* Insert system clock initialization code here (sysclk_init()). */
sysclk_init();
board_init();

configure_console();

while (1) {
printf("abc");
}

return 0;
}

这适用于具有 SAM3X8E Controller 的 Arduino Due。

关于无法使用 printf 命令构建 atmel studio 6.2 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33115350/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com