[Atmel] SAM4S 串口虚拟printf打印输出浮点数

[复制链接]
1499|4
 楼主| maydolly 发表于 2015-7-21 11:58 | 显示全部楼层 |阅读模式
编译环境:Atmel Studio 6.2
按下面方式虚拟串口
#ifdef __GNUC__
/* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf
     set to 'Yes') calls __io_putchar() */
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif /* __GNUC__ */
PUTCHAR_PROTOTYPE
{
/* Place your implementation of fputc here */
/* e.g. write a character to the USART */
  Send_Data((uint8_t) ch);
/* Loop until the end of transmission */

return ch;
}  
打印的时候,字母数字符号什么的都正常,但是输出浮点数结果全是 f(0x66),请问有哪位知道原因吗?
ddllxxrr 发表于 2015-7-21 20:30 | 显示全部楼层
Send_Data((uint8_t) ch);
就是这句,强制类型转换。字母数字没问题,浮点在GCC中也许就是那个结果
 楼主| maydolly 发表于 2015-7-22 11:19 | 显示全部楼层
ddllxxrr 发表于 2015-7-21 20:30
Send_Data((uint8_t) ch);
就是这句,强制类型转换。字母数字没问题,浮点在GCC中也许就是那个结果 ...

啊?不是吧,我在keil中这样写就没问题啊
并且printf里面对float有转换成unsigned char吧
我查查看,多谢
 楼主| maydolly 发表于 2015-7-22 11:19 | 显示全部楼层
ddllxxrr 发表于 2015-7-21 20:30
Send_Data((uint8_t) ch);
就是这句,强制类型转换。字母数字没问题,浮点在GCC中也许就是那个结果 ...

啊?不是吧,我在keil中这样写就没问题啊
并且printf里面对float有转换成unsigned char吧
我查查看,多谢
yicole 发表于 2015-7-27 10:37 | 显示全部楼层
学习了!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

主题

3

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部