Hello fellow freaks,
I'm using AS6.2 which comes with GCC 4.8.1, which supports named address spaces such as __flash. However, I have some confusion about how and when I can use variables that are declared as being in that space. Is my understanding correct that once I've declared a variable "const __flash", I can use that variable anywhere (in C code, not ASM) that I could use a variable only declared "const", and the compiler will take care of the rest? For example, this means that I only have to write one version of a function that accepts a pointer to an array of const chars:
void function(const char *string);
and then I can pass it a string in RAM or in flash:
const char string1 = "This string is in RAM"; const __flash char string2 = "This string is in flash"; function(string1); function(string2);
without any changes?
However, if the function is written in ASM, like much of avr-libc, then different functions are required for accessing RAM or flash (e.g. the "_P" suffixed functions) because the compiler doesn't generate the code for accessing the parameters? And so I can't pass a string declared with "__flash" into either the regular or "_P" version of an avr-libc function, so I still need to use the PSTR() macro if I want to pass a string located in flash?
Hopefully someone can help me understand named address spaces better.
Thanks in advance,