Last Updated: December 26, 2018
·
2.255K
· alxlo

When using PROGMEM, pgm_read_byte() or pgm_read_word() returns unexpected values?

You are using the PROGMEM attribute to keep e.g. tables in program memory to safe RAM ?
Some other parts of your code work just fine, but reading those PROGMEM data via pgmreadbyte() or pgmreadword() doesn't give you the expected values?

Maybe your avrdude is using the wrong binary files for programming. When you are passing a .elf file to avrdude you are probably running into trouble, as the addresses in the ELF binary will not fit your memory layout. Try giving the generated .hex file to avrdude instead.