问题描述
我想通过 usart 从 stm32f405 注销.在我的 syscall.c 文件中,我实现了通过 usart 打印的功能:
I want to log out from stm32f405 via usart.In my syscall.c file i realize function to print via usart:
int _write(int file, char *ptr, int len)
{
int todo;
for (todo = 0; todo < len; todo++)
{
usart_send_char( *ptr++ );
}
return len;
}
函数 usart_send_char( *ptr++ );
按预期工作.但是当我打电话时:
Function usart_send_char( *ptr++ );
work as expected. But when i call:
printf("%s, %d, %3.2f\r\n", "asd", 777, 13.2 );
我得到:asd, 777, 0.00
浮点变量未正确打印.
I get: asd, 777, 0.00
The float variable not printed correctly.
生成文件:
PROCESSOR = -mcpu=cortex-m4 -mthumb -mfloat-abi=softfp -mfpu=fpv4-sp-d16
CFLAGS += $(PROCESSOR) $(INCLUDES) $(STFLAGS) -Wall -fno-strict-aliasing $(C_PROFILE)
LDFLAGS = $(PROCESSOR) -Wl,-Map=$(PROG).map,--cref,--gc-sections
使用的编译器:
Sourcery CodeBench Lite 2014.05-28
我错在哪里?
推荐答案
我没有为 STM32F4 使用 Sourcery Codebench gcc,但是使用 GCC ARM Embedded 工具链,默认情况下不启用 printf 中的浮点支持.要启用,请将 -u _printf_float
添加到您的 LDFLAGS.
I haven't used Sourcery Codebench gcc for STM32F4, but with the GCC ARM Embedded toolchain, floating point support in printf isn't enabled by default. To enable, add -u _printf_float
to your LDFLAGS.
这篇关于stm32 printf 浮点变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!