DPRG List  

[DPRG] AVR sprintf problem

Subject: [DPRG] AVR sprintf problem
From: sagun maini sagun_smart at yahoo.com
Date: Tue Jul 18 08:38:36 CDT 2006

what compiler are u using.....

Kipton Moravec <kip at kdream.com> wrote:
  You left out some very important details. Let me guess them.

1. You are using the WinAvr compiler.
2. You did not run Mfile.
3. As a result your linker does not use the printf and scanf library
that supports floating point (the default is no floating point to save

You need to run Mfile. Or go to your makefile find where it says:

#Additional libraries.

# Minimalistic printf version
PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min

# Floating point printf version (requires MATH_LIB = -lm below)
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt

PRINTF_LIB = $(PRINTF_LIB_FLOAT) <--- Change yours to look like this

# Minimalistic scanf version
SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min

# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt

SCANF_LIB = $(SCANF_LIB_FLOAT) <--- Change yours to look like this

See if that fixes you up. 

I know this from experience. I had the same problem and after a few days
of trying different things thought the compiler was broken, and finally
asked in the AVRfreaks WINAVR forum.


On Tue, 2006-07-18 at 00:58 -0500, Scott Sumner wrote:
> Hello all,
> I'm using the ADC in an Atmega88 to read a voltage and display it on a set
> of 7 segment LEDs. I'm succesfully reading the ADC because I can output the
> result register directly and the number reflects changes in the
> potentiometer. However, as soon as I do the math to convert it to voltage
> and attempt to sprintf the decimal value into my string I get a blank
> display. I'm using a double to store the conversion result and have tried
> %f, %lf, %3.3lf, etc. as the sprintf format string. Any ideas?
> Thanks,
> Scott
> scott at lighthouse21.com
> _______________________________________________
> DPRGlist mailing list
> DPRGlist at dprg.org
> http://list.dprg.org/mailman/listinfo/dprglist
Kipton Moravec 

DPRGlist mailing list
DPRGlist at dprg.org

Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://list.dprg.org/pipermail/dprglist/attachments/20060718/183fc99e/attachment.html

More information about the DPRG mailing list