|
发表于 2011-12-21 11:15:07
|
显示全部楼层
回复【楼主位】xiake017
#include <iom8v.h>
#include <stdio.h>
#define uchar unsigned char
#define uint unsigned int
#include "usart.c"
void main()
{
float i=32.2;
uchar num[5];
uart_init(9600);//初始化串口
while(1)
{
// send_str("asdfa\r");//测试串口
sprintf(num,"%f",i);//格式化成为字符串
send_str(num);//串口打印
}
}
我这是一个简单的例程,就是把浮点数转换为字符串,按照标准格式写的,但是显示不出来,我在keil里面做测试能够转换出来,为什么在iccavr编译环境里面不行,请高手指教,
-----------------------------------------------------------------------
printf is supplied in three versions, depending on your code size and feature requirements (the more features, the higher the code size):
![](http://cache.amobbs.com/bbs_upload782111/files_49/ourdev_706351T42WHS.jpg)
(原文件名:允许sprintf()转换32位数字串.jpg)
藏得很坑爹。。 |
|