Ardino due and sprintf() on Atmel Studio 6.1 doesn't work!

Hello to all,
excuse me for my question, I don't know if I can post it in this forum.

I am using Atmel Studio 6.1 to program Arduino Due and I would like to print a float number in a buffer.

If I write:
char bf [40];
int F = 1234;
sprintf (bf, "% d", F);

everything works fine and I find the integer number in the buffer "bf".
if instead I write

char bf [40];
float F = 1234.0;
sprintf (bf, "%f", F);

does not work and I don't find the float number in the buffer "bf" .

if I use Arduino IDE 1.5.2 everything works fine.
someone has a suggestion?
where am I wrong?

Best regards
Davide

The sprintf used by the AVR's does not have float support, or many other sprintf features.

Here is a library I'm working on at the moment, there is a working 'GString' library which contains an sprintf function:
String/sprintf alternative for Arduino.

However this requires the Print library, which you'll have if you use the Arduino core.

Than you very much, it's exactly that I was looking for!
Very beautiful work, my compliments.
I thank you very much.
At the first test it seems to work very well.
Best regards.
Davide

That is good to hear, I don't actually have a Due to do any testing, so your response was great. Cheers. :slight_smile:

Oops, I just realized now that I had made ??a mistake and had not included your library but I printed an integer with sprintf of atmel, that's why it seemed to work! :slight_smile:
I was too tired when I took the test.
when I have time I'll try again including your library. Thanks again and sorry for the error.
Davide

No worries, there shouldn't be problems as the version you have does not include the eeprom or progmem code. I'm working on a print library extension that allows Serial.printf(). It is only AVR compatible at the moment as I build the functionality, but eventually I can mask off the AVR only bits and I'll have support for the Due as well.

You should be fine to use the GString.h, though.

How exactly are you able to program the ARM chip through Atmel Studio? This is killing me.

I use an add-in for Atmel Studio 6.1 called Visual Micro. I can program all my Arduino boards, including Due, using it.

Check it out (it is free)http://www.VisualMicro.com

Here is a screenshot