Skip to main content
added 154 characters in body
Source Link
Juraj
  • 18.3k
  • 4
  • 32
  • 50

The constant uses (like pat[6]) are replaced at compile time.

If you want to get a value from PROGMEM you must read it with pgm_read functions. Read the PROGMEM reference.

for (int i = 0; i < 8; i++) {
  Serial.print(pgm_read_byte_near(pat + i),HEX);
}

pat[0] in Serial.print(pat[0],HEX); is an item in a constant array const uint8_t pat[]. it can't change at runtime so the compiler uses the value 0xFF. that is why it is printed ok without pgm_read_byte_near

The constant uses (like pat[6]) are replaced at compile time.

If you want to get a value from PROGMEM you must read it with pgm_read functions. Read the PROGMEM reference.

for (int i = 0; i < 8; i++) {
  Serial.print(pgm_read_byte_near(pat + i),HEX);
}

If you want to get a value from PROGMEM you must read it with pgm_read functions. Read the PROGMEM reference.

for (int i = 0; i < 8; i++) {
  Serial.print(pgm_read_byte_near(pat + i),HEX);
}

pat[0] in Serial.print(pat[0],HEX); is an item in a constant array const uint8_t pat[]. it can't change at runtime so the compiler uses the value 0xFF. that is why it is printed ok without pgm_read_byte_near

edited body
Source Link
Juraj
  • 18.3k
  • 4
  • 32
  • 50

The constant uses (like pat[6]) are replaced at compile time.

If you want to get a value from PROGMEM you must read it with pgm_read functions. Read the PROGMEM reference.

for (int i = 0; i < 8; i++) {
  Serial.print(pgm_read_word_nearpgm_read_byte_near(pat + i),HEX);
}

The constant uses (like pat[6]) are replaced at compile time.

If you want to get a value from PROGMEM you must read it with pgm_read functions. Read the PROGMEM reference.

for (int i = 0; i < 8; i++) {
  Serial.print(pgm_read_word_near(pat + i),HEX);
}

The constant uses (like pat[6]) are replaced at compile time.

If you want to get a value from PROGMEM you must read it with pgm_read functions. Read the PROGMEM reference.

for (int i = 0; i < 8; i++) {
  Serial.print(pgm_read_byte_near(pat + i),HEX);
}
Source Link
Juraj
  • 18.3k
  • 4
  • 32
  • 50

The constant uses (like pat[6]) are replaced at compile time.

If you want to get a value from PROGMEM you must read it with pgm_read functions. Read the PROGMEM reference.

for (int i = 0; i < 8; i++) {
  Serial.print(pgm_read_word_near(pat + i),HEX);
}