Go Down

Topic: prog_char and pgm_read_byte won't work (Read 5186 times) previous topic - next topic


Running the following program results with "10B 91" on the Serial Monitor indicating 0x91 is stored at or read from address 0x010B rather than 0x00. Please advise. Any and all help is appreciated.

Code: [Select]


byte flag=0;
prog_char jazz0=0x00;

void setup() {

void loop() {
 if (flag == 0) {
   Serial.print  ((int)&jazz0, HEX);
   Serial.print  (' ');
   Serial.println(pgm_read_byte(&jazz0), HEX);

Coding Badly

Dec 17, 2009, 06:59 am Last Edit: Dec 17, 2009, 06:59 am by bcook Reason: 1

I have no idea why your code does not work but this does work...

Code: [Select]
prog_char jazz0 PROGMEM =0x00;


Dec 17, 2009, 10:10 am Last Edit: Dec 17, 2009, 10:11 am by GrooveFlotilla Reason: 1
Can someone explain the syntax of this one please?
Code: [Select]
typedef char PROGMEM prog_char; (from "pgmspace.h").

Code: [Select]
prog_char jazz0 PROGMEM =0x00;
somewhat tautological?

Would a simple "const" suffice?
Per Arduino ad Astra


Your help is appreciated. "prog_char jazz0 PROGMEM =0x00;" works. All is now well.

Coding Badly

isn't somewhat tautological?

My suspicion is there is a bug or deficiency in the compiler.

Would a simple "const" suffice?

No.  The difference is where the data is stored.  PROGMEM places the data in Flash.  const places the data in SRAM.


Looks like the same bug described here:

There hasn't been any word on this since I submitted the bug to the gcc group back in august.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131