> -----Original Message-----
> From: 
> avr-gcc-list-bounces+eweddington=cso.atmel....@nongnu.org 
> [mailto:avr-gcc-list-bounces+eweddington=cso.atmel....@nongnu.
> org] On Behalf Of Robert von Knobloch
> Sent: Monday, February 02, 2009 8:49 AM
> To: avr-gcc-list@nongnu.org
> 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


_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Reply via email to