I want to put a table in Flash and read it directly from my C program. According to Microchip this is done by __attribute__((space(psv)))
However, as the most things around microchip, their own examples doesn't work that well (usually obsolete and not updated): https://microchipdeveloper.com/16bit:psv
So this is what I'm trying to do:
uint16_t __attribute__((space(psv))) ConfDiskImage[] = {
/*AOUT*/ 0x01E0,0x0004,0x3333,0x4053,
/* 1*/ 0x01E1,0x0012,0x0005,0x0000,0x0000,0x0000,0x4120,0x0000,0x0000,0x0000,0x4120,
/* 2*/ 0x01E2,0x0012,0x0006,0x0000,0x0000,0x0000,0x4120,0x0000,0x0000,0x0000,0x4120,
/* 3*/ 0x01E3,0x0012,0x0007,0x0000,0x0000,0x0000,0x4120,0x0000,0x0000,0x0000,0x4120,
/*EOD */ 0x0000,0x0000
};
When I compile I get: "warning: ignoring space attribute applied to automatic ConfDiskImage"
I'm using MPLAB X IDE 5.45 with XC16-gcc v1.50. Microcontroller: dsPIC33EP256MC506
Any ideas of how to get it to stay in Flash (not being copied to RAM) and read it directly from flash with a pointer?
I suspect what you really need is perhaps more involved but the simple answer to the question you asked is to use the
const
storage class.For example: