Page 1 of 1

How to setup data array in program flash

Posted: Sat Jan 21, 2012 10:28 am
by MarkW
Hi All,

I am looking at using a 18F25K22 for a project, where i need to setup a block
of reference data in a section of the program flash memory. This data is not to
be written to flash on every power up, but is put there at program time (when
the chip is programmed). How do i setup this array in the code program such that
the compiler / programmer puts it into flash memory without main program control?
Do you have to setup a C code block with directive commands to the compiler to do this?
I would imagine something like declaring a memory area in flash and then the data array
to be put there..........also how does one read data from that program memory flash once
the main program is running?
I have other questions as well regarding this, but i would like to focus on this issue first!

Regards

Mark

Re: How to setup data array in program flash

Posted: Sat Jan 21, 2012 11:18 am
by medelec35
Hi Mark,
A simular question was asked here:
http://www.matrixmultimedia.com/mmforum ... =31&t=7389

Hope this helps.

Martin

Re: How to setup data array in program flash

Posted: Sat Jan 21, 2012 8:25 pm
by MarkW
Hi Martin

Thanx for the link, interesting problem...but not what i am after. That link
was about writing/reading from the main program running in the chip.

My question was how to setup a compiler directive or whatever in the program
code such that at program time(Hex file into chip), the data block is written
into the flash area by the device programmer. This data is to be non-volatile
therefore the need to put permanently into flash, but not under program
control...but by the programmer tool itself when reading the compiled hex file.........

Thanx

Mark

Re: How to setup data array in program flash

Posted: Sat Jan 21, 2012 9:54 pm
by medelec35
Ah I see now.

What I would do is crate the Flowchart you want to use then compile to hex.
load hex in your programmer.
Now where you see the large group FF you can enter your own data. save hexfile then compile to chip

Or if you know an address you want to save data within flowcode use a c block with:
#pragma DATA address, data1, data2, data3 etc.
Or
#pragma DATA address, “abcdefg1”, “abcdefg2”
“abcdefgX” is a character string, th
charcters will be stored as 8 bit value.

Not tried it my self.

But got that information from BoostC manual

Martin

Re: How to setup data array in program flash

Posted: Sun Jan 22, 2012 11:11 am
by MarkW
Thanx Martin!

I did bit of looking up in the datasheet and BoostC manual and yes i think you
are correct. I think there are a few methods one can achieve this taking a closer look
now at the question.....
Does FC4 have any macros etc to do table read/writes? you need these commands to
access and control the flash memory, otherwise it seems i must create c block with some asm
to do the commands.

But yes, the first question was basically sorted (thanx again Martin).

The next question concerns reading that flash data within FC. I am assuming one has to use the
table read commands to put the data in variables etc ?

How about it FC developer guys? (Ben / Steve etc)....lets have some more macros with advanced
functions like this!

Thanx guys

Mark

Re: How to setup data array in program flash

Posted: Mon Jan 23, 2012 1:13 pm
by Steve
One thing to note is that not all chips allow internal flash R/W. This is one reason it has not been implemented in Flowcode.

But things might change soon. We have big plans for the components and hope to greatly expand support in this area.