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.

TMS320F28377D: 使用printf发送数字,只能发送第一位数据,发送小数只能发送第一位的整数

Part Number: TMS320F28377D


我在使用printf功能的时候,遇见了发送数字不正确的情况:

一、我的配置:

1.1、我的重映射函数:

/*printf函数*/

#include "stdio.h"
#include "string.h"
#include "driverlib.h"
#include "device.h"
#include "board.h"
int fputc(int ch,FILE *fp)
{
SCI_writeCharBlockingFIFO(MySCI485_BASE, ch);
return ch;
}

int fputs(const char *_ptr,FILE *_fp)
{
uint16_t len;
len = strlen(_ptr);
SCI_writeCharArray(MySCI485_BASE,(uint16_t *)_ptr,sizeof(len));
return len;
}

我在主函数中一直循环调用以下函数:

void vofa_Test(void)
{
static float t1 = 0;
static float t2 = 0;
static float t3 = 0;
printf("simple:%f,%f,%f\n",sin(t1),sin(t2),sin(2*t3));
DEVICE_DELAY_US(100000);
t1 = t1 + 0.1;
t2 = t2 + 0.2;
t3 = t3 + 0.5;
}

上位机接收运行结果为:

问题:没有显示出小数,只有0和—;

二、我做了以下尝试:

2.1、我改变了我的重映射函数为:

/*printf函数*/

#include "stdio.h"
#include "string.h"
#include "driverlib.h"
#include "device.h"
#include "board.h"
int fputc(int ch,FILE *fp)
{
SCI_writeCharBlockingFIFO(MySCI485_BASE, ch);
return ch;
}

int fputs(const char *_ptr,FILE *_fp)
{
uint16_t len;
len = strlen(_ptr);
SCI_writeCharArray(MySCI485_BASE,(uint16_t *)_ptr,len);
return len;
}

运行结果为:

貌似超出打印范围一样,我该如何修改或者配置才能正确使用printf函数打印小数的结果?