Page 1 of 1

printf with floats

Posted: Sun Mar 12, 2017 4:17 pm
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!

Re: printf with floats

Posted: Fri Mar 17, 2017 3:16 am
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