printf with floats

Topics for the Eclipse Environment
Post Reply
vardelean
Posts: 1
Joined: Sun Mar 12, 2017 4:08 pm

printf with floats

Post by vardelean »

Hi everyone,

Very quick question, in case you guys have seen this before: can't print floats on debug port using printf (not iprintf for integers, just the regular printf).

Using SBL2e, NBEclipse Release 2.8.2, I have my debug port on Serial 1. Here's the code:

Code: Select all

#include <predef.h>
#include <stdio.h>
#include <ctype.h>
#include <basictypes.h>
#include <serialirq.h>
#include <system.h>
#include <constants.h>
#include <ucos.h>
#include <netif.h>
#include <autoupdate.h>
#include <smarttrap.h>


extern "C" {
void UserMain(void * pd);
}

const char * AppName="MyFloatTest";

void UserMain(void * pd) {
    SimpleUart(1,SystemBaud);
    assign_stdio(1);
    InitializeStack();
    OSChangePrio(MAIN_PRIO);
    EnableAutoUpdate();

   printf("Application started\n");

   float myFloat = 1.2345;

   printf("My float = %f\n", myFloat);


   while (1)
    {
        OSTimeDly(TICKS_PER_SECOND);
    }
}
And the output is:

Application started
My float = f


I tried everything, changed the format specifiers, etc. to no avail.

Any hints?

Many thanks!
User avatar
pbreed
Posts: 1088
Joined: Thu Apr 24, 2008 3:58 pm

Re: printf with floats

Post by pbreed »

This is an issue with 2.8.x and the SBL2E.

This should be fixed in 2.8.3 (released in the next few days, may even be released now)

If your not short on space 2.8.2 brings almost no new features to the SBL2E so you can go back to 2.7.x


Paul
Post Reply