element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • 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
Personal Blogs
  • Community Hub
  • More
Personal Blogs
Legacy Personal Blogs Switch from TI-RTOS to SimpleLink POSIX: EEPROM API
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 11 May 2018 4:40 PM Date Created
  • Views 970 views
  • Likes 3 likes
  • Comments 2 comments
  • firmware
  • rtos
  • msp432
  • launchpad
  • code_composer_studio
  • posix
Related
Recommended

Switch from TI-RTOS to SimpleLink POSIX: EEPROM API

Jan Cumps
Jan Cumps
11 May 2018

A real world migration from TI-RTOS to the POSIX API of TI SimpleLink.

Texas Instruments migrated from the proprietary TI-RTOS to the open POSIX API.

I'm migrating a project that extensively used the TI paradigms to that POSIX API. You're my witness.

image

The blog assumes that you are a TI-RTOS user and want to adapt to the new ways of working.

 

This time the topic is SimpleLink and MSP432 DriverLib related. Not POSIX specific, but an impact of switching to SimpleLink.

Where the original driver lib for the MSP432 used the Flash API (see git), the SimpleLink release uses EEPROM API.

The functions are similar but there's less work defining where the data is stored. No more messing with the linker command file and fixed addresses.

The new API does that for you. You still have to give an offset in the EEPROM memory area, but we're using 0 - start of the block.

You don't need to explecitly unprotect and protect the memory in the new API. It's simpler to use.

 

I'm using the API to persistently store calibration data and retrieve it at startup of the Programmable Electronic Load.

 

Initialising the API

 

Initialise the API before you use it.

Because it's not often used in my firmware (in normal use only a single EEPROM read at startup) I've lazily chosen to try and initialise it whenever I call an API function,

with a static flag to skip the initialisation if it's already done.

Feel free to criticise in the comments. I have some weak defense points.

 

#include <ti/devices/msp432e4/driverlib/eeprom.h>

 

void calibrationInit() {
    static bool bInited = false;
    if(!bInited) {
        /* Enable the EEPROM peripheral. */
        SysCtlPeripheralEnable(SYSCTL_PERIPH_EEPROM0);


        /* Initialize the EEPROM */
        EEPROMInit();
        bInited = true;
    }
}

 

I've made a structure to capture the data. This is unchanged from the old TI-RTOS approach.

The only difference is the CALIBRATION_START definition. It used to be an addres in the Flash range. Now it's an offset in the dedicated non-volatile storage range of the controller.

 

#define CALIBRATION_DATA_VERSION 1U
#define CALIBRATION_START 0x00


typedef struct CalibrationData {
    uint32_t version;
    float temperature_threshold;  // todo convert to the ADC 16 bit value in stead of float
    float sense_voltage_read_multiplier;
    float sense_voltage_read_offset;
    float current_read_multiplier;
    float current_read_offset;
    float current_write_multiplier;
    float current_write_offset;
} CalibrationData;


#define CALIBRATION_DATA_SIZE (sizeof(CalibrationData))


CalibrationData _CalibrationData;

 

Reading Data

 

Very simple. Tell the API where the EEPROM offset is (the persistent source), where the data needs to be copied to (the in-memory calibration structure) and the size of the data ( == the size of that calibration structure).

 

void calibrationRead() {
    calibrationInit();
    EEPROMRead((uint32_t *)&_CalibrationData, (uint32_t)(CALIBRATION_START),
               (uint32_t)CALIBRATION_DATA_SIZE);
}

 

Writing Data

 

Also simple. Do the same logic as above, but the other way around: from RAM to persistent Flash.

 

void calibrationWrite() {
    _CalibrationData.version = CALIBRATION_DATA_VERSION; // writing calibration data will always set the version to the latest
    calibrationInit();
    EEPROMProgram((uint32_t *)&_CalibrationData, (uint32_t)(CALIBRATION_START),
                  (uint32_t)CALIBRATION_DATA_SIZE);
}

 

That's it.

If you'd check out the same code I wrote for the original MSP432 driverlib (see git), you'd see that it was a little deeper under the hood (not a lot - still understandable) and that you'd use memcpy() to move data from Flash to RAM.

Everything got a little bit simpler and easier to code.

 

The ext blog will very likely be POSIX related. The only non-POSIX topic I have to cover later on is the LCD driver (SimpleLink has a driver for that - yay).

 

Related Blog
Switch from TI-RTOS to SimpleLink POSIX: Threads and Semaphores
Switch from TI-RTOS to SimpleLink POSIX: EEPROM API

Switch from TI-RTOS to SimpleLink POSIX: From MailBox to Message Queue

Switch from TI-RTOS to SimpleLink POSIX: LCD Display Driver
Switch from TI-RTOS to SimpleLink POSIX: Sleep when Idle
  • Sign in to reply
  • Jan Cumps
    Jan Cumps over 7 years ago in reply to DAB

    It's an adaption exercise, Don. I jumped the typical RTOS loops before.

    I'd say that the core RTOS complexity has increased a little for newcomers, because thz configuration GUI has been placed on the backburner.

    The driverlib became simpler.

     

    For POSIX skilled people the whole package will be easier because they know the API.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 7 years ago

    Nice post Jan.

     

    Do you find Simplelink easy to use?

     

    DAB

    • 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