cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1 MCU

GuNo_288966
New Contributor II

Hi,

   

for a project with a CY8Y5856 with a display I need to store lots of text to be displayed.

   

How can I put the text into the program memory so that it does not waste RAM?

   

The text should be stored in a struct or at least in an array.

   

Best regards,

   

Günter

0 Likes
8 Replies
odissey1
Honored Contributor II

 How many bytes you are looking to store?

   

odissey1

0 Likes
EvPa_264126
Valued Contributor II

   

for PSoC3 I use the following:

   

   

const uint8 code TestStr[1024]={0};

   

   

for PSoC4 and 5 seems to need another ...

0 Likes
GuNo_288966
New Contributor II

Hi,

   

there will be about 400 "strings" of 20 bytes each (several languages on the display).

   

It seems that the "const" keyword does the job for PSoC5LP.

   

Thanks,

   

Günter

0 Likes
ETRO_SSN583
Esteemed Contributor

Re the ARM compilers -

   

 

   

    

   

                    

   

I would have liked to see a different solution like a "flash" qualifier, but GCC developers have choosen a different solution. Now the "const" qualifier has two different meanings depending on the context it appears.

   

Used in a parameter-list the consequences are: the parameter will not be modified by a direct assignment.

   

Used in a variable declaration and followed by an initialization the variable will be put into the code area which will be flash memory in all embeddeds.

   

This improvement is not ARM specific but works in GCC generally.

   

http://www.keil.com/support/docs/2829.htm     Abs variable location Keil and ARM GCC

   

 

   

Regards, Dana.

0 Likes
HeLi_263931
Honored Contributor II

Actually its not really something gcc invented. The different meanings of const are defined in the C / C++ standards. Its merely an optimization gcc can do that const strings / fields can be put to flash memory.

0 Likes
ETRO_SSN583
Esteemed Contributor

Hli, can you point put where in the standard const adresses storage class ?

   

I cannot seem to find it.

   

 

   

    

   

          http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899

   

 

   

Regards, Dana.

0 Likes
HeLi_263931
Honored Contributor II

Like I said, the C/C++ standard addresses the different semantics of const (namely that the affected variable / field is not to be modified, and depending on context is either a requirement or a guarantee).

   

GCC (when compiling for embedded environments) uses this information to handle variable placement in flash or volatile memory. So in that sense GCC has added an additional meaning to const, but it still has the other one as before.

0 Likes
JoMe_264151
Expert II

Excerpt from AN89610    www.cypress.com/

   
    It is more efficient to have all constant data, for example fixed data tables in arrays, be located in flash, however the default is to place them in SRAM.   
   
    To force placement of a variable in     flash, set its type to const and explicitly initialize it,   
   
    for example:   
   
    uint32 const var_in_flash = 0x1234567   
   

Bob

0 Likes