Skip to content

Instantly share code, notes, and snippets.

@nerdralph
Created April 11, 2021 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nerdralph/891fba0d06a874c024ef012a77e2b38a to your computer and use it in GitHub Desktop.
Save nerdralph/891fba0d06a874c024ef012a77e2b38a to your computer and use it in GitHub Desktop.
avr-gcc extern __flash array bug
#include <stdint.h>
extern __flash const uint8_t digital_pin_to_bit_mask_PGM[];
uint8_t read_array(uint8_t i)
{
return digital_pin_to_bit_mask_PGM[i]; // bug: uses ld
// return *(digital_pin_to_bit_mask_PGM + i); // uses lpm
}
void setup() {
// put your setup code here, to run once:
}
extern "C" uint8_t read_array(uint8_t index);
void loop() {
// put your main code here, to run repeatedly:
PORTB = read_array(PINB);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment