Hi
I have an array of pin numbers they are part of a library and I'm using them with interrupts
External Interrupts and with Timer 3 output compare. I have declared the array as volatile I was wondering if I could put this array in flash memory since it the values never change? How would I do that inside a library? I'm using the values stored for digitalWrite and digitalRead. It works as I have it just fine but I'm wasting 12 bytes on sram do it the way I have below I'm using the 2560 board.
Thanks
Don
// variable used by interrupts
volatile uint8_t eomFlag = 0;
volatile uint8_t rxPins[] = {5,6,7,9,10,11}; // would like to put in flash memory
volatile uint8_t cdPins[] = {21,20,19,18,02,03}; // would like to put in flash memory
If the values don't change, use them as 'const' and not 'volatile'.
The 'volatile' is for variables that can be changed in an interrupt, without knowing when that happens.
To place code in Flash, see this, PROGMEM - Arduino Reference
The problem is that you can't use them as variables, you have to use a function to read them. The pgm_read... functions.
You need also to add the PROGMEM keyword to put them into flash memory.
If they are in flash memory, you can't use them anymore. You will need those pgm_read.... functions.