SW500010 Microchip Technology, SW500010 Datasheet - Page 262

HI-TECH C PRO FOR PIC10/12/16

SW500010

Manufacturer Part Number
SW500010
Description
HI-TECH C PRO FOR PIC10/12/16
Manufacturer
Microchip Technology
Type
Compilerr
Series
PIC10/12/16r
Datasheets

Specifications of SW500010

Supported Families
PIC10, PIC12, PIC16
Core Architecture
PIC
Software Edition
Professional
Kit Contents
Software And Docs
Mcu Supported Families
PIC10/12/16
Tool Type
Compiler
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
PIC10, PIC12, PIC14, PIC16, PIC16E
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
Other names
019P
778-1006
778-1006
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
262
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 * /
Library Functions

Related parts for SW500010