#ifdef __FLASH
const __flash int var = 1;
-int read_i (void)
+int read_var (void)
@{
- return i;
+ return var;
@}
#else
-#include <avr/pgmspace.h> /* From avr-libc */
+#include <avr/pgmspace.h> /* From AVR-LibC */
const int var PROGMEM = 1;
-int read_i (void)
+int read_var (void)
@{
- return (int) pgm_read_word (&i);
+ return (int) pgm_read_word (&var);
@}
#endif /* __FLASH */
@end example
accesses to these data will read from generic address space, i.e.@:
from RAM,
so that you need special accessors like @code{pgm_read_byte}
-from @w{@uref{http://nongnu.org/avr-libc/user-manual,avr-libc}}.
+from @w{@uref{http://nongnu.org/avr-libc/user-manual,AVR-LibC}}
+together with attribute @code{progmem}.
@b{Limitations and caveats}
@code{__memx}.
@item
-If you use one if the @code{__flash@var{N}} address spaces
+If you use one of the @code{__flash@var{N}} address spaces
you will have to arrange your linker skript to locate the
@code{.progmem@var{N}.data} sections according to your needs.
In order to read data located with the @code{progmem} attribute
(inline) assembler must be used.
@example
-/* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual,avr-libc}} */
+/* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual,AVR-LibC}} */
#include <avr/pgmspace.h>
/* Locate var in flash memory */