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

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

RE: [avr-gcc-list] Accessing function and strings in flash in theATMega


From: Weddington, Eric
Subject: RE: [avr-gcc-list] Accessing function and strings in flash in theATMega 644
Date: Mon, 2 Feb 2009 09:06:11 -0700

 

> -----Original Message-----
> From: 
> address@hidden 
> [mailto:address@hidden
> org] On Behalf Of Robert von Knobloch
> Sent: Monday, February 02, 2009 8:49 AM
> To: address@hidden
> Subject: [avr-gcc-list] Accessing function and strings in 
> flash in theATMega 644
> 

>  if (pgm_read_byte((PGM_P)(TESTIMAGE + (IMAGE_SIZE * projnum) +
> SIGNATURE) != 0))
<snip> 
> Can anyone tell me a: why this does not work and/or what I am assuming
> that is wrong?

Remember that pgm_read_byte() is a *macro* and not a function. And to top it 
off, that macro generates inline assembly. You have a very complex expression 
in the parameter portion of the macro.

I strongly suggest that you take out the expression and assign it to another 
variable, and just use that variable in place of the pgem_read_byte() 
paramater. As a precaution, take out the call to pgm_read_byte() from the if 
statement.

Like so:

address = (TESTIMAGE + (IMAGE_SIZE * projnum) + SIGNATURE);
byte = pgm_read_byte(address);
if (byte != 0)
{
// code
}

See if that helps.

Eric Weddington




reply via email to

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