Thanks Brain for the suggestion. I did that and AVR Studio is still
messed up.
-----Original Message-----
From: Brian Dean [mailto:bsd@bdmicro.com]
Sent: Tuesday, April 12, 2005 1:18 AM
To: AVR-Chat@yahoogroups.com
Subject: Re: [AVR-Chat] Strcmp() problem stepping through AVR Studio
On Sun, Apr 10, 2005 at 10:51:01PM -0400, wbounce wrote:
> If have serveral strcmp statements
>
> Originally I had them all like this.
>
> if (strcmp("GPGGA",gcBuffer) == 0)
> {
> gpFieldPtr=(PGM_P) GGA;
> }
>
> It would execute the pointer assignment on each of the 8 statements
>
> I changed them to
>
> lnResult = strcmp("GPGLL",gcBuffer);
> if (lnResult == 0)
> {
> gpFieldPtr=GLL;
> }
>
> So I could see the result code of strcmp. This time it skipped the 1st
> 3 ok but then started doing the assignments. And when it got to the
> strcmp that should have matched, lnResult was not 0 and yet it did the
> assignment anyhow.
>
> Anyone have any idea why?
I'm not sure about the problem, but just a quick observation. With
AVR-GCC, string references like above consume both Flash as well as
precious RAM. It can add up quickly, too. To rewrite those to save RAM
space, try:
strcmp_P(PSTR("GPGLL"),gcBuffer);
This references the string data directly from Flash and saves making a
copy of it to RAM.
-Brian
--
Brian Dean
BDMICRO - ATmega128 Based MAVRIC Controllers http://www.bdmicro.com/
Yahoo! Groups LinksMessage
RE: [AVR-Chat] Strcmp() problem stepping through AVR Studio
2005-04-13 by wbounce
Attachments
- No local attachments were found for this message.