Storing and retrieving 11KB fixed data within program code. AVR & PIC

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times

Re: Storing and retrieving fixed data within program code.

Post by LeighM »

Hmm, well the XC8 compiler manual indicates that the const will place the data in ROM space.
But ...
For baseline PIC devices, the maximum size of a single const object is 255 bytes.
However, you can define as many const objects as required provided the total size
does not exceed the available program memory size of the device.
Also it seems that PIC has to copy this into RAM before use, which makes it more like an initialized variable than a const.
Having done most of my recent "C" years on ARM, this is all coming back as a bit of a shock :lol:

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: Storing and retrieving fixed data within program code.

Post by medelec35 »

Hi Leigh,
It needs testing but have solved it so now compiles.
Instead of:

Code: Select all

const unsigned char Image1[] =
I moved char position:

Code: Select all

char const unsigned Image1[] =
LeighM wrote: Also it seems that PIC has to copy this into RAM before use, which makes it more like an initialized variable than a const.
I'm guessing the first is treated like a variable as you stated so uses RAM, whereas the second places it in ROM?
LeighM wrote:Having done most of my recent "C" years on ARM, this is all coming back as a bit of a shock :lol:
All of it is a shock to me, At least you know C :lol:

Thanks again for all your help, Much appreciated. :)
Martin

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times

Re: Storing and retrieving fixed data within program code.

Post by LeighM »

Hi Martin,
Yes you are correct, bit of a typo on my part, forgetting image1 is pointer, so the pointer and data it points to can be const

Code: Select all

const char const Image1[] =

Post Reply