Skip to content

Using pgm_read_word returns unexpected results #447

Closed
@caternuson

Description

@caternuson

This seems related to issue #79 and PR #81.

Here is the test sketch:

static const PROGMEM uint16_t wordtable[] = {
  0b1000000011110111,
  0b1011001100110011,
  0b1000000000000001,
  0b1000000110000001,
};

void setup() {
  Serial.begin(9600);
  while(!Serial);
  Serial.println("PROGMEM Test.");

  Serial.print("0b"); Serial.println(pgm_read_word(wordtable + 0), BIN);
  Serial.print("0b"); Serial.println(pgm_read_word(wordtable + 1), BIN);
  Serial.print("0b"); Serial.println(pgm_read_word(wordtable + 2), BIN);
  Serial.print("0b"); Serial.println(pgm_read_word(wordtable + 3), BIN);
}

void loop() {
}

This returns:

PROGMEM Test.
0b1000000011110111
0b11001110000000
0b1011001100110011
0b110110011

Changing the preproc logic to #if 1 to engage the original pgm_read_ macros produces expected results:

PROGMEM Test.
0b1000000011110111
0b1011001100110011
0b1000000000000001
0b1000000110000001

EDIT: adding BSP version used: 1.9.14

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions