MSP430FR variables to FRAM

So I use MSP430FR because it has FRAM. But it also has 1 kB of SRAM and all the variables and the stack is in the SRAM. That is no fun I want my data do be safe and maybe even survive a power off.

First idea is to use static addresses. But that is super bothersome and error prone to more than 2 variables.

Fortunately there is linker command file in the Code Composer Studio project - lnk_msp430fr5739.cmd. I found lines 119 to 121. They say that variables and stack should be in ram. One simple hack later and:

.bss       : {} > FRAM          /* GLOBAL & STATIC VARS */
.data      : {} > FRAM          /* GLOBAL & STATIC VARS */
.stack     : {} > FRAM (HIGH)   /* SOFTWARE SYSTEM STACK */

Checked it out with debugger, and indeed. All variable memory locations were in FRAM area (device datasheet, pg 23, Table 6. Memory Organization).

Fun - but.. but... there are restrictions that apply!

1. FRAM speed is 8 MHz

So if your MCU is faster then all operations with memory will be delayed a bit. There is some caching, but my application run at 8 MHz and everyone else's even slower so whatever.

2. FRAM is non volatile

You can be extra sure that all your variables contain random values at startup. Or - not random, but the same that they had on last power down.

3. FRAM is not indestructible

Datasheed explicitly warns about it. But also it says that it will survive 1015 writes. Most read and writeable variable in my code is i. It is the counter in inner loop. It gets read or written (endurance wears with reading too, it has destructive reading) about 5 times per loop. Inner loop runs 100 times and the outer loop runs at 600 Hz. So my code writes the variable at 5*100*600 Hz = 300 kHz. With this much use the FRAM will be destroyed in - 105.62 years... So.. I think I'm good.

Share
Posted on 2013-01-16, 01:25 By
No comments yet Categories: Soft

Leave a Reply

Your email address will not be published. Required fields are marked *