5.16 __load_program_memory Intrinsic Function
The IAR __load_program_memory
intrinsic function reads one byte from the
specified code memory within the lower 64kB of program memory.
Suggested Replacement
There is no MPLAB XC8 equivalent built-in function; however, library functions and plain C code can perform a similar task.
Use the pgm_read_byte()
function to read a byte of program
memory.
Alternatively, cast the address to a const __flash unsigned char *
pointer and dereference it in the usual way.
Caveats
The pgm_read_byte()
function takes an integer argument, not a
pointer.
Examples
volatile unsigned char val;
__flash unsigned char myVar = 0x55;
void foo(void) {
unsigned char __flash * dp = &myVar;
val = __load_program_memory(dp);
}
to
MPLAB XC8 code similar
to:#include <avr/pgmspace.h>
const __flash myVar = 0x55;
int main(void)
{
unsigned char val;
val = pgm_read_byte(&myVar);
}
Further Information
See the Library Functions and Special Type Qualifiers sections in the MPLAB XC8 C Compiler User's Guide for AVR MCUs for more information on the library function and qualifier.