cancel
Showing results for 
Search instead for 
Did you mean: 

How to store large constant arrays in flash not in RAM

artvolk
Associate II
Posted on May 06, 2011 at 13:18

How to store large constant arrays in flash not in RAM

6 REPLIES 6
luca239955_stm1_st
Senior II
Posted on May 17, 2011 at 15:12

for Cosmic, just declare an object ''const'' and it will be stored in flash.

artvolk
Associate II
Posted on May 17, 2011 at 15:12

Thanks for the quick reply!

Do you know will it work for Raisonance (I've already this toolchain installed at home). There are defines in stm8s.h (from Standard Periph Library) where they redefine const to CONST for different compilers. Is this the same?

Another question -- how to check that data goes to flash and not in RAM -- check .lst file?

artvolk
Associate II
Posted on May 17, 2011 at 15:12

It seems I figured it out:

for Raisonance:

Memory space modifiers

.

A specific memory space can be specified for each variable using RCSTM8-specific keywords such as bit, code, data, page0, eeprom, fcode, and fdata. Hardware Registers can be accessed through more specific keywords such as hbit, hreg and hreg16.

artvolk
Associate II
Posted on May 17, 2011 at 15:12

Thank you all for the quick and accurate responses! It work for me!

brunorichard9
Associate II
Posted on May 17, 2011 at 15:12

On Raisonance, adding the ''code'' memory space qualifier will do it:

code char BigBuf[1024] = ''This is a very large buffer stored in Flash'';

You can have further detail in the application note AN55 from Raisonance from 

http://forum.raisonance.com/viewtopic.php?pid=9418#p9418

.

vincent.philippe
Associate II
Posted on May 17, 2011 at 15:12

Hi

1/ For check the placement for variables or functions you need to read the .map file generated by linker.

2/ For a placement in FLASH with Raisonance compiler you need to use the word ''code''. In fact with Raisonance compiler the keyword ''const'' is for a write protection for datas but not the placement in specific area.

3/ The best way is to use the define word ''__CONST'', in this case you use the correct words without builder dependency.

Best regards

Phil