English
Language : 

PIC24F04KA201 Datasheet, PDF (49/224 Pages) Microchip Technology – 14/20-Pin General Purpose, 16-Bit Flash Microcontrollers with nanoWatt XLP™ Technology
PIC24F04KA201 FAMILY
EXAMPLE 5-2: ERASING A PROGRAM MEMORY ROW – ‘C’ LANGUAGE CODE
// C example using MPLAB C30
int __attribute__ ((space(auto_psv))) progAddr = &progAddr; // Variable located in Pgm Memory
unsigned int offset;
//Set up pointer to the first memory location to be written
TBLPAG = __builtin_tblpage(&progAddr);
offset = &progAddr & 0xFFFF;
// Initialize PM Page Boundary SFR
// Initialize lower word of address
__builtin_tblwtl(offset, 0x0000);
NVMCON = 0x4058;
asm("DISI #5");
__builtin_write_NVM();
// Set base address of erase block
// with dummy latch write
// Initialize NVMCON
// Block all interrupts for next 5 instructions
// C30 function to perform unlock
// sequence and set WR
© 2009 Microchip Technology Inc.
Preliminary
DS39937B-page 47