Jump to content
43oh

FLASH, RAM and usage calculation


Recommended Posts

Suppose you have an application like SimpliciTi that says:" low memory needs(<8kB flash and 1kB RAM depending on the configuration)", you also have in your program the Petit FAT file system: "Very small RAM consumption (44 bytes work area + certain stack), Very small code size (2K-4K bytes)", finally you have some inertial sensors to calculate some angles, like in Nine-Axis Sensor Fusion Using the Direction Cosine Matrix Algorithm on the MSP430F5xx Family AppNote, where you need RAM ~ 0.75 kB, Flash ~ 11.7 kB.

Summarizing:

flash 8kB       + RAM 1 kB

flash 4kB       + RAM 44 B

flash 11.7kB  + RAM 0.75 kB

 

How do you choose the memory requirements for the microcontroller. The flash should be big enough to acomodate all the applications. Is the same case with the RAM? should I add together those values? Is the RAM used only when I'm using that particular app, for example I need 0.75kB only when I'm doing the math for the sensor fusion?

 

Thanks!

Link to post
Share on other sites

In general probably depends on the application.  Some RAM may need to be in use continuously

(to retain values - e.g. what was the last sector used in file system, previous sensor values used in averaging, etc.)

 

Look at the libraries to see what global variables they use - it is easiest to figure you need space for all of those

values.  (If a library only needs the global while it is in operation you might be able to do overlays and make

it share space with something else, but coding and maintaining may be challenging.)

Link to post
Share on other sites

Often for prototyping it's easiest to just buy the largest family member of the microcontroller you wish to use.

 

MSP430's make this esspecially easy because the code is compatible between all devices. (may need some device specific module changes)

 

 

 

Once you're satisfied your code is performing to your application needs you could run a simple memory analysis.

  1. Fill memory with known values 0xDEAD and 0xBEEF are common filler values.
  2. Run your program long enough to have run though all your code, while connected to a debugger.
  3. pause with the debugger, and examine the internal memory. You can find the point where the memory was used and no longer is still a 0xDEAD value.

If you can see that you have plenty of space free in RAM, you could decide if you want to purchase a cheaper device.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...