Functions for Erasing and Writing EEDATA Memory

These functions support the erasing and writing of EEDATA memory for devices that have this type of memory.

Examples of Use

Example 1: dsPIC30F DSCs

#include "libpic30.h" 
#include "p30fxxxx.h" 

char __attribute__((space(eedata), aligned(_EE_ROW))) dat[_EE_ROW]; 

int main() { 
  char i,source[_EE_ROW]; 
  _prog_addressT p; 

  for (i = 0; i < _EE_ROW; ) 
    source[i] = i++; /* initialize some data */ 

  _init_prog_address(p, dat); /* get address in program space */ 
  _erase_eedata(p, _EE_ROW); /* erase a row */ 
  _wait_eedata(); /* wait for operation to complete */ 
  _write_eedata_row(p, source); /* write a row */ 
} 

Example 2: PIC24FXXKA MCUs

#include "libpic30.h" /* should use <> here */ 
#include "p24Fxxxx.h" 

int __attribute__((space(eedata), aligned(_EE_4WORDS))) dat[_EE_4WORDS/2]; 

int main() { 
  _prog_addressT p; 
  _init_prog_address(p, dat); /* get address in program space */ 
  _erase_eedata(p, _EE_4WORDS); /* erase the dat[] array */ 
  _wait_eedata(); /* wait to complete */ 
  _write_eedata_word(p, 0x1234); /* write a word to dat[0] */ 
  _wait_eedata(); 

  p += 2; 
  _write_eedata_word(p, 0x5678); /* write a word to dat[1] */
  _wait_eedata(); 
}