In general, the PROGMEM in older AVR-Toolchains contains a macro in avr/pgmspace.h that contains the following definition:
#define PROGMEM __ATTR_PROGMEM__
...
typedef char prog_char PROGMEM;
This is since a couple of Versions of the Toolchain, this "type" declaration marked as "Depricated". The reason is, that the GNU-C/C++ Compiler does'nt supports memory attribute on a type definitions. The recommended usage is, to use the attribute on the variable instead of the type definition. The explain and further programming of attribute are found here:http://www.codeforge.com/article/41705 .
if you define a uint8_t array of values, you need to declare them as const instead static.
const uint8_t arr[] = PROGMEM {"this is just a test that shoud stored into the Programm memory space\n"};
uint8_t char_from_progmem;
uint8_t readstring_P (const uint8_t *str)
{
retbyte = pgm_read_byte (str) ;
return (retbyte);
}
// ############# call that function ######################
char_from_progmem = readstring_P(arr);
The compiler does'nt need to know what memory segment the pointer of str points, just the address is needed. The access to the program memory do the
pgm_read_byte (str) function for us. This need just the address and assume, that the memory is the program space instead data segment.
The document from Dean Camera describe further details about the progmem handling.
bye the way, the depricated SIGNAL() function for ISR callbacks are also describted by Dean Camera and i would recomment his "actual" Documentation of all the hints about the newer toolchain and recommended programming.
rasco22862:
I am leading with a strange error using the PROGMEM space that I can't understand. Here is the temp code that I have been using to figure out the problem: