User Tools

Site Tools

한국어

moacon:framwrite:index

framWrite

void framWrite(u16 fadr, u8 fData)

fAdr : Address in FRAM to write data
fData: Data to write

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.

Writes fData to FRAM address fAdr. Addresses 0 through 0x7EFF are available for use. The last 256 bytes, addresses 0x7F00 through 0x7FFF, are reserved for the system and should not be used.

#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 to MOACON Home

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