SW500007 Microchip Technology, SW500007 Datasheet - Page 246

PICC-18 PRO

SW500007

Manufacturer Part Number
SW500007
Description
PICC-18 PRO
Manufacturer
Microchip Technology
Type
Compilerr
Series
PIC18r
Datasheets

Specifications of SW500007

Supported Families
PIC18
Core Architecture
PIC
Software Edition
Professional
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
015P
778-1002
778-1002
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 SW500007