avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Floating point on Mega32


From: E. Weddington
Subject: Re: [avr-gcc-list] Floating point on Mega32
Date: Mon, 26 Jan 2004 12:39:57 -0700

On 26 Jan 2004 at 10:39, Douglas Dotson wrote:

> 
> --- "E. Weddington" <address@hidden> wrote:
> > On 26 Jan 2004 at 9:05, Douglas Dotson wrote:
> > 
> > > Greetings!
> > > 
> > > I am attempting to use floating point on a Mega32.
> > > 
> > > double x;
> > > char str [20];
> > > x = 3.14;
> > > sprintf (str, "%5.2lf", x);
> > > usartTransmitString (str);
> > > 
> > > The result is a ? is displayed.
> > > 
> > > I', sure it is something simple, but this my first
> > > time
> > > using gcc on AVR.
> > > 
> > 
> > Are you sure you're linking in the floating point
> > version of the printf 
> > library?
> > 
> 
> No. I haven;t linked in anything other than the
> defaults in the Makefile. Is this part of libm?
> I've looked in the docs but didn;t see anything
> related to linking in floating support other than
> libm.
> 

Ah, it's sounds like you're not linking it in. No, it's not part of libm, 
that's just the math library.

When printf (and family) was introduced to avr-libc, it was split up into 
different libraries mainly due to code size. There is a separate printf lib 
that includes floating point, however this is the biggest version of the printf 
library. Something to take note when incorporating it into the mega32.

If you're using Windows and using WinAVR, the sample makefile that comes with 
WinAVR does not automatically link in the printf library. Go to the sample 
makefile where it links in libm (search for: LDFLAGS += -lm) and right above it 
are some statements (commented out) that you can use to link in the printf 
library of your choice.

Or, to make your life easier, use MFile:
<http://www.sax.de/~joerg/mfile/>
which can automatically generate makefiles for use with AVR GCC, whether on 
Windows or *nix. The makefile template for the Windows version is based on the 
WinAVR sample makefile

HTH


reply via email to

[Prev in Thread] Current Thread [Next in Thread]