This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
工具/软件:Code Composer Studio
1、相同 代码:
#include "msp430.h"
#include "stdio.h"
float A=10.5;
/**
* main.c
*
int main (空)
{
WDTCTL = WDTPW | WDTHOLD;//停止看门狗计时器
while (1)
{
printf ("%f"、a);
}
}
int fputc (int _c、寄存器文件*_fp)
{
while (!(UCA0IFG&UCTXIFG));
UCA0TXBUF =(无符号字符)_c;
return ((unsigned char)_c);
}
2、printf 支持
3、代码大小
4、为什么 CCS 使用大代码量、但仅支持 print ("%s")、而不支持 print ("%f")和 print ("%d")、而 IAR 使用小代码量、但支持所有代码?
[引用 user="user4324449">为什么 CCS 使用大代码量、但仅支持 print ("%s")、而不支持 print ("%f")和 print ("%d")我查看了使用 TI MSP430编译器 v18.1.5.LTS 的示例
当调用 printf()来格式化 float "%f"或整数"%d"时,运行时库内部会使用格式化的输出构建一个字符串,然后调用 fputs()来输出格式化的字符串。 因此,在程序中添加 fputs()函数的实现。 例如:
int fputs (const char *_ptr、file *_fp) { while ((*_ptr)!='\0') { fputc (*_ ptr、_fp); _PTR++; } 返回0; }
我发现添加 fputs()也减少了程序使用的 RAM 和闪存数量,但仍然使用了更多的 IAR 内存。