[Top][All Lists]

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

Re: [avr-gcc-list] printf_P question

From: Joerg Wunsch
Subject: Re: [avr-gcc-list] printf_P question
Date: Fri, 3 Jun 2005 07:09:11 +0200 (MET DST)

"wbounce" <address@hidden> wrote:

> //Variable definitions
> volatile double gnLatDegree, gnLongDegree;
> volatile uint8_t gnValidData;
> volatile double gntrackgood;
> volatile double gngroundspeedknots;
> volatile int16_t TargetBearing,SlowBearing, CurrentBearing;

Umm, that many volatile variables -- it will make your application
pretty slow I guess.

> Long  75.217300 Lat 40.166611 H 263.10 Kn   0.70 CB   0.0 TB  48.5 V
> CB is 0.0 even if I set CurrentBearing = TargetBearing

Offhand no idea for that, perhaps the parameter passing of so many
(and so large) parameters is broken somehow.  You should inspect the
compiler-generated assembly code.

> volatile uint32_t DistanceFeet,LeftDistance,
> LastLeftDistance,RightDistance, LastRightDistance;

> printf_P(PSTR("CL %i LD %i CR %i RD %i D %f
> \n"),CurrentLeft,LastLeftDistance,CurrentRight,LastRightDistance,Distanc
> e);

This is plain wrong.  uint32_t objects need %lu in terms of AVR.

> Is there some problem with printf and global volatile  variables?

Global or volatile is unimportant, as the compiler needs to copy the
variables down the stack for printf, it doesn't pass references or

cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)

reply via email to

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