Store look up table in the Flash memory

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Mrinal
Level 4
Level 4
First solution authored 50 replies posted 25 replies posted

I want to store a 10 bit sine table in the flash during programming and access it during runtime. How to go about this?

   

Please provide relevant information and resources related to flash IO

   

Thanks

0 Likes
8 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Easiest solution:

   

static const int16 SineTable[NumEntries] = {0,2, and so on };

   

This will be put into flash because of the "static const" and  the initialization. Both are required.

   

 

   

Bob

0 Likes
Mrinal
Level 4
Level 4
First solution authored 50 replies posted 25 replies posted

Ok now it's getting slightly unclear. (M new to programming, please bear)

   

If declaring and initializing a constant string stores the value in the flash, why do we need dedicated API functions for the same. I think I came across something like "CYC_Read or CYC_write" not exactly the same, but similar.

   

App notes are in bits and pieces for learning the basics.

   

Please suggest a good book on ARM programming in C using the GCC standard library. I can't find one after searching a lot.

   

Thank you

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

I only know of the GCC documentation which explains things that are special to ARM in some chapters. This is not a PSoC special function, but implemented by Gnu C.

   

The different methods are not the "same", my suggestion does not store the table on a specific address which can be done using one of the other approaches.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

flash based constant tables are your best friend. we do a lot of look-up tables, xml definition files, character to pixel tables, translate tables with function pointers etc. all in flash.

   

 

   

like Bob said you have to do static and const (and for pointers even more const) in your definitions to make the compiler save it all in flash. the default action is to save it in flash but at start-up copy into ram, which you don't want unless it has to be capable of modification.

   

 

   

declare your stuff, then look on the .map file to make sure it is stored in flash.

   

 

   

Ed

0 Likes
Mrinal
Level 4
Level 4
First solution authored 50 replies posted 25 replies posted

Please could you provide me a link to the GCC Compiler documentation...

   

Thank you!

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

The link is gcc.gnu.org

   

 

   

Bob

0 Likes
Mrinal
Level 4
Level 4
First solution authored 50 replies posted 25 replies posted

Thank you!

0 Likes