element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
In the Air Design Challenge
  • Challenges & Projects
  • Design Challenges
  • In the Air Design Challenge
  • More
  • Cancel
In the Air Design Challenge
Blog AirMobile - 19 - Memory retention
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: amgalbu
  • Date Created: 13 Jan 2015 10:57 AM Date Created
  • Views 586 views
  • Likes 3 likes
  • Comments 3 comments
  • fram
  • iot_distributed
  • msp_430
  • in_the_air
  • in-the-air
Related
Recommended

AirMobile - 19 - Memory retention

amgalbu
amgalbu
13 Jan 2015

Memory retention

AirMobile sensor is going to be switched off abruptly whenever the Peltier cell does not provide enough energy. I need to save application status to resume execution properly after a "black-out"

The MSP430FR MCUs features an internal FRAM to store persistent data in place of the typical Flash. FRAM is a non-volatile memory technology that is uniquely flexible and can be used for program or data memory. It can be written to in a bit-wise fashion and with virtually unlimited write cycles

Variables are allocated in SRAM by the default linker command files. FRAM-based MSP430FR5969 device has 2KB of SRAM. If the variable size is too large to fit in SRAM, the linker command file can be modified or C-language #pragma directives can be used to allocate specific variables or structures in FRAM memory.

The toolchains available for MSP430 all ship with linker command files that define a default memory setup and partitioning, typically allocating program code and constant data into FRAM, and variable data and the system stack to SRAM. In addition, C compiler language extensions are provided that allow you to locate selected variables and data structures into FRAM, allowing you to utilize the benefits of using FRAM for persistent data storage without any further considerations regarding memory partitioning or modifications of the linker command files.

In CCS, there are two C language pragma statements that can be used: #pragma PERSISTENT and #pragma NOINIT. PERSISTENT causes variables to not get initialized by the C startup routine, but rather the debug tool chain initializes them for the first time as the application code is loaded onto the target device. Subsequently, those variables do not get initialized, for example, after a power cycle as they have been completely excluded from the C startup initialization process. Declaring variables as PERSISTENT causes them to get allocated into the .TI.persistent linker memory segment.

Here is a code snippet showing how the variable is declared as persistent:

 

#pragma PERSISTENT(x)
 unsigned int x = 5;

 

NOINIT works similar to PERSISTENT but the variables are never initially initialized by the project’s binary image file and the debug tool chain during code download. Declaring variables as NOINIT causes them to get allocated into the .TI.noinit linker memory segment. Note that unlike PERSISTENT, variables declared as NOINIT do not get located in FRAM by the default linker command files, requiring a minor modification of the linker command file if such functionality is required. Here is a corresponding code snippet:

#pragma NOINIT(x)
unsigned int x;

The basic flowchart of the AirMobile firmware is very simple

 

image

 

So I decided to save the application status and the last readings of the 5 sensors


#pragma PERSISTENT(gAppPhase);
int gAppPhase = PHASE_READING_TEMP_RH_NO2;

typedef struct
{
      float temperature;
      float humidity;
      float CO;
      float NO2;
      float dust;
} SENSORS_DATA;
 
#pragma PERSISTENT(SENSORS_Data);
SENSORS_DATA SENSORS_Data;

 

The application status is saved for obvious reason.

The last readings are saved in order to make a mobile average over the samples

  • Sign in to reply

Top Comments

  • tomaja
    tomaja over 10 years ago in reply to amgalbu +1
    Ahh, cost, right. I forgot about that factor
  • tomaja
    tomaja over 10 years ago in reply to amgalbu

    Ahh, cost, right. I forgot about that factor image

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • amgalbu
    amgalbu over 10 years ago in reply to tomaja

    As far as i know the major problem in FRAM technology is cost. So you can just integrate a few kilobytes of FRAM in an MCU whereas you can integrate Megabytes of FLASH.

    I don't know about retention time, but I can imagine it's comparable to  Flash as the MSP430FR stores code in FRAM...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • tomaja
    tomaja over 10 years ago

    Very interesting post. It will be useful for all of us.

    FRAM seems superior over Flash:

         1. Much less power required

         2. Faster read/writes

         3. Virtually unlimited number of write cycles

    Do you know of some case where Flash is better performer?

     

    Dragan

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube