NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Microcontroller Programming » printf_P problems
November 19, 2012 by Volleygod |
For the skimmers: Simply put here is the code :
here is the result: ? I can not for the life of me print floats, doubles, etc. I am sure it is something really simple I am missing but I can not figure out why??? For those who want the whole story: Ok I feel really stupid asking this question. I am a self-taught programmer (mostly web apps) I have working in many languages for many years and I am just making the move to micro controllers and C. I ordered the nerdkit a week or so ago and really love it. I have learned pretty quickly and can usually find any answer online. But this one has me stumped and I have googled the *** out if and haven't found anything due to the nature it is hard to get accurate search results. This started with the temp sensor project, but I quickly dismissed it and moved on because I really wanted to get to the scale project. (I am working on a project that uses strain gauges) I got everything working great except anytime I try to print a float it comes out with a ? It is driving me crazy... for my own purposes I wrote a application in C# (my primary language) to show the results (similar to the python program with the project) Again everything else works fine. I simplified the code to just print and it happens. Here is the entire code:
|
---|---|
November 19, 2012 by Volleygod |
Oh yea I forgot to mention... I assume since no one else has reported this it is a compiler thing. I am using Atmel Studio 6 and have already turned off optimization. |
November 19, 2012 by Volleygod |
Well since adding the last comment it helped me figure out search terms for the problem, I think I have found the solution and will try it when I get home. Sometime just posting the question helps answer it ;-) |
November 20, 2012 by Ralphxyz |
Volleygod, please post your answer. There have been about a hundred post here in the Nerdkits forum referencing printf_P I am surprise you didn't find an answer. As printf_P often causes problems there should be an article in the Nerdkits Community Library. Ralph |
November 20, 2012 by Volleygod |
It was just hard to find a solution because of the "?" I found dozend where printf_P wasn't working but to try and search for "?" or question mark didn't narrow the results. I did find the solution after realizing I needed to search for "Atmel Studio 6 printf float" Which led me to Here It was a simple solution as I expected: for anyone in the future using Atmel Studio you must "...add -lprintf_flt or -lscanf_flt to the linker options which is done by listing printf_flt as a library." |
Please log in to post a reply.
Did you know that you need to think about wires differently when you're transmitting signals more than a few inches? Learn more...
|