PIC24FJ64GA306-I/MR Microchip Technology, PIC24FJ64GA306-I/MR Datasheet - Page 87

no-image

PIC24FJ64GA306-I/MR

Manufacturer Part Number
PIC24FJ64GA306-I/MR
Description
16-bit, 16 MIPS, 64 KB Flash, 8 KB RAM, 53 I/O, LCD, XLP W/Vbat 64 QFN 9x9x0.9mm
Manufacturer
Microchip Technology
Datasheet
EXAMPLE 6-2:
EXAMPLE 6-3:
EXAMPLE 6-4:
 2010-2011 Microchip Technology Inc.
// C example using MPLAB C30
//Set up pointer to the first memory location to be written
; Set up NVMCON for row programming operations
; Set up a pointer to the first program memory location to be written
; program memory selected, and writes enabled
; Perform the TBLWT instructions to write the latches
; 0th_program_word
; 1st_program_word
;
; 63rd_program_word
2nd_program_word
unsigned long progAddr = 0xXXXXXX;
unsigned int offset;
TBLPAG = progAddr>>16;
offset = progAddr & 0xFFFF;
__builtin_tblwtl(offset, 0x0000);
NVMCON = 0x4042;
asm("DISI #5");
__builtin_write_NVM();
MOV
MOV
MOV
MOV
MOV
MOV
MOV
TBLWTL W2, [W0]
TBLWTH W3, [W0++]
MOV
MOV
TBLWTL W2, [W0]
TBLWTH W3, [W0++]
MOV
MOV
TBLWTL W2, [W0]
TBLWTH W3, [W0++]
MOV
MOV
TBLWTL W2, [W0]
TBLWTH W3, [W0]
DISI
MOV.B
MOV
MOV.B
MOV
BSET
NOP
NOP
BTSC
BRA
#0x4001, W0
W0, NVMCON
#0x0000, W0
W0, TBLPAG
#0x6000, W0
#LOW_WORD_0, W2
#HIGH_BYTE_0, W3
#LOW_WORD_1, W2
#HIGH_BYTE_1, W3
#LOW_WORD_2, W2
#HIGH_BYTE_2, W3
#LOW_WORD_63, W2
#HIGH_BYTE_63, W3
#5
#0x55, W0
W0, NVMKEY
#0xAA, W1
W1, NVMKEY
NVMCON, #WR
NVMCON, #15
$-2
ERASING A PROGRAM MEMORY BLOCK (‘C’ LANGUAGE CODE)
LOADING THE WRITE BUFFERS
INITIATING A PROGRAMMING SEQUENCE
PIC24FJ128GA310 FAMILY
; Block all interrupts with priority <7
; for next 5 instructions
; Write the 0x55 key
;
; Write the 0xAA key
; Start the programming sequence
; Required delays
; and wait for it to be
; completed
// Address of row to write
// Initialize PM Page Boundary SFR
// Initialize lower word of address
// Set base address of erase block
// with dummy latch write
// Initialize NVMCON
// Block all interrupts with priority <7
// for next 5 instructions
// check function to perform unlock
// sequence and set WR
;
; Initialize NVMCON
;
; Initialize PM Page Boundary SFR
; An example program memory address
;
;
; Write PM low word into program latch
; Write PM high byte into program latch
;
;
; Write PM low word into program latch
; Write PM high byte into program latch
;
;
; Write PM low word into program latch
; Write PM high byte into program latch
;
;
; Write PM low word into program latch
; Write PM high byte into program latch
DS39996F-page 87

Related parts for PIC24FJ64GA306-I/MR