User Tools

Site Tools




u8 framRead(u16 fadr)

fAdr : Address in FRAM to write data

The MOACON has 32KB of FRAM (Ferroelectric Random Access Memory) memory. It is non-volatile so it retains data even without power.Retaining memory between power cycles has traditionally been implemented using EEPROMs or battery backup.

Battery backup uses a battery to maintain memory in internal SRAM. However, the battery must be monitored to ensure it has a charge and is replaced periodically, which places a maintenance burden on the operators.

EEPROMs incur a few milliseconds of latency when writing and are limited in the number of write-erase cycles.FRAM can retain data for about 10 years without the need for a battery backup, has a lower writing latency,and has a greater maximum number of write-erase cycles.

Gets a byte of data from FRAM address fAdr.

The following program demonstrates reading and writing to FRAM. If FRAM does not contain the string “Comfile Technology” at address 0, the string is written to FRAM. After writing to FRAM, if the MOACON is powered off and powered back on, the string will be retained.

#include "moacon500.h"
#include <string.h>
void cmain(void)
    char text[STRING_LEN];
    const char* const comfile = "Comfile Technology";
    const u8 STRING_LEN = 19;           //"Comfile Technology" plus '\0' terminator
    u8 i = 0;
    for(i=0; i< STRING_LEN; i++)        //Clear text one character at a time
        text[i] = '\0';
    for(i=0; i<STRING_LEN-1; i++)        //Read data from FRAM one byte at a
    {                                    //time and store in variable text
        text[i] = framRead(i);
    if (strcmp(text, comfile) != 0)      //If text does not equal comfile,
        for(i=0; i<STRING_LEN-1; i++)    //write comfile to FRAM
        {                                //one byte at a time
            framWrite(i, *(comfile+i));
        printf("\"%s\" written to FRAM\r\n", comfile);
    else                                 //if text equals comfile
        printf("FRAM contains \"%s\"\r\n", comfile);

go MOACON home

moacon/framread/index.txt · Last modified: 2016/04/14 11:07 (external edit)