SW500008 Microchip Technology, SW500008 Datasheet - Page 246

PICC-18 STD

SW500008

Manufacturer Part Number
SW500008
Description
PICC-18 STD
Manufacturer
Microchip Technology
Type
Compilerr
Series
PIC18r
Datasheets

Specifications of SW500008

Supported Families
PIC18
Core Architecture
PIC
Software Edition
Standard
Kit Contents
Software And Docs
Mcu Supported Families
PIC18
Tool Function
Compiler
Tool Type
Compiler
Lead Free Status / RoHS Status
Not applicable / RoHS Compliant
For Use With/related Products
PIC18 Series
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
Other names
015
778-1001
778-1001
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
232
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 SW500008