LC60: What can I do if I need more flash program memory?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LC60: What can I do if I need more flash program memory?

1,597 Views
BasePointer
Contributor II
Hi,
 
I'm developing a project with LC60 and my program size is now 54KB. I'm uneasy about flash size of LC60 and afraid of that the project will not be fit to LC60. What can I do if I really need more flash?
 
Thank you.
Labels (1)
0 Kudos
4 Replies

287 Views
UcTechnoGeek
Contributor II
I would agree with the serial Flash solution.
 
Serial SPI flash is getting much larger, cheaper and more companies offer it (Atmel, ST, Intel, ...).  Also, it's footprint compatible so, if you need more storage, buy a larger memory device.
 
Use it to store all you tables, menus, ect..  and there is very little change to your application code.
 
This is what I did for a similar voice application.
 
uCTechnoGeek
0 Kudos

287 Views
tonyp
Senior Contributor II
Here's some more ideas (for either Assembly or Higher-Level language), in no particular order:

Minimize the use of parameters for functions by replacing them with global variables, where possible, and to the extent RAM availability allows.  This will reduce the amoung of SP based instructions (that have a one byte penalty each) and cut down the size a bit.

Remove unused code and data (e.g., strings, tables) from libraries.

Replace general purpose routines with shorter more specific ones.  For example, if you have a general purpose routine that converts binary to ASCII string but uses 32-bit integers, and you only need support for 8-bit, a lot of code will be removed.

In the same spirit, use variables no bigger than what is actually needed.  It's not just the RAM you save but also all the related manipulation code.  Possible automatic size or type conversions in various statements should be considered, also, as they too add code.

Search for common statements in different functions and replace them with functions themselves.  In higher level languages, it is easy to casually repeat statements because they're easier to write inline than setup a function to do them.

If your original is in Higher-level language and all other advice fails, you can rewrite portions or even the whole thing in assembly for huge savings in program space (1/10th the original size or better is usually feasible).
0 Kudos

287 Views
rocco
Senior Contributor II
Hi, BasePointer:

I think the question is "What Can I do when my program gets too big for the flash that I have?" You can't add more flash, and there is not an HC08 or S08 processor with more than 60k of flash, so we need to figure out how to keep you within 60k.

I assume that you are writing in C, so the first thing might be to look at the optimizations available with your C compiler. You will need to optimize for size, at the potential cost of performance. That part is always painful to me, but I sometimes do it anyway.

Then there is the impact of the libraries that you may be using. You might be able to select more compact library functions, or recompile the libraries that you are using with different optimizations.

The biggest impact I have ever encountered is when I remove floating-point and replace it with fixed-point. Floating-point is real convenient in C, but often the same results can be obtained with fixed point. But not without pain. Unfortunately, there is no fixed point support native to C, so it is code that you need to write yourself, using integers.

Lastly, I seem to remember that your system contains an LCD. Do you use much flash space for text strings? If so, are there common words in those strings? I have saved a LOT of space in string tables by tokenizing the common words.

I'm sure others will have more ideas.
0 Kudos

287 Views
peg
Senior Contributor IV
Hi BP,
An extension of Rocco's idea would be to keep LCD strings (and perhaps some other data currently stored in FLASH) in a serial memory device. The LCD is slow anyway so you could just transfer the data straight from external memory to the LCD. Probably give away any tokenising if you do this.
 
0 Kudos