All,
I've used sprintf with no problems many times. But in my current program when I try and print out a floating point number I just get question marks.
sprintf(buffer, "%f", 4.1);
After running that line, buffer contains the string: "???"
Is there maybe a compiler option that is disabling floating point?
Thanks, Matt
How would the compiler/linker know that you are using floating point? Do you perform any floating point operations? By the way - do you have the commercial version of uVision?
I am using the commercial uvision V4.02.
Since I am adding to an existing project, one that never used floating points in the past, I was wondering if there might be some option that takes out floating point math in order to optimize the code. If I just start a new project it seems to work fine... So I suspect that there is just some configuration that I am missing.
... why not just insert somewhere a = 4.7 * 5.2 and see what happens.
sometimes a quick test is waaaay faster than a forum discussion.
Erik
I did try that. The math works but sprintf just prints out "???"
I think I've tried all the "quick" things. I tried %g instead of %f but the same thing. int, strings, unsigned ints and unsigned long ints seem to work just fine.
The problem appears to only be with floats.
The unique thing about this card is that it talks to the CP2200 Ethernet chip and I have used the Silicon Labs TCP-IP Configuration wizard and included:
mn_stack_bank_038.lib mn_stack_common_038.lib mn_callback.c mn_vars.c
When I add these to a test project I get it to fail in the same way.
Is there something in those library files overwriting how sprintf works?
Appearently printf is being pulled in from the mn_stack_common_038.lib file and not the standard file. Probably no way to include both, guess I'll use ftoa examples and create my own function.
So have you asked Silicon Labs about this?
If they're overloading printf, they should provide a complete implementation - or some way for you to get at the original...