SW500009 Microchip Technology, SW500009 Datasheet - Page 233

HI-TECH FOR DSPIC/PIC24

SW500009

Manufacturer Part Number
SW500009
Description
HI-TECH FOR DSPIC/PIC24
Manufacturer
Microchip Technology
Type
Compilerr
Series
PIC24 & DsPICr
Datasheet

Specifications of SW500009

Supported Families
PIC24
Core Architecture
PIC, DsPIC
Software Edition
Standard
Kit Contents
Software And Docs
Tool Type
Compiler
Mcu Supported Families
PIC24 MCUs And DsPIC DSCs
Lead Free Status / RoHS Status
Not applicable / RoHS Compliant
For Use With/related Products
DSPIC3X/PIC24
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
Other names
025
778-1003
778-1003
Library Functions
PERSIST_CHECK, PERSIST_VALIDATE
Synopsis
Description
The persist_check() function is used with non-volatile RAM variables, declared with the persistent
qualifier. It tests the nvram area, using a magic number stored in a hidden variable by a previous call
to persist_validate() and a checksum also calculated by persist_validate(). If the magic number and
checksum are correct, it returns true (non-zero). If either are incorrect, it returns zero. In this case it
will optionally zero out and re-validate the non-volatile RAM area (by calling persist_validate()).
This is done if the flag argument is true.
set up the magic number and recalculate the checksum.
Example
The persist_validate() routine should be called after each change to a persistent variable. It will
#include <sys.h>
int persist_check (int flag)
void persist_validate (void)
#include <sys.h>
#include <stdio.h>
persistent long reset_count;
void
main (void)
{
if(!persist_check(1))
else
reset_count++;
persist_validate();
for(;;)
printf("Reset count invalid - zeroed\n");
printf("Reset number %ld\n", reset_count);
continue;
/* sleep until next reset */
/* update count */
/* and checksum */
219

Related parts for SW500009