1 ;********************************************************************
4 ; Processor: PIC24H Family
5 ; Hardware: Explorer 16
6 ; Assembler: ASM30 2.14
7 ; Company: Microchip Technology, Inc.
9 ; Software License Agreement
11 ; The software supplied herewith by Microchip Technology Incorporated
12 ; (the “Company” for its PICmicro® Microcontroller is intended and
; supplied to you, the Company’s customer, for use solely and
; exclusively on Microchip PICmicro Microcontroller products. The
; software is owned by the Company and/or its supplier, and is
; protected under applicable copyright laws. All rights are reserved.
; Any use in violation of the foregoing restrictions may subject the
; user to criminal sanctions under applicable laws, as well as to
; civil liability for the breach of the terms and conditions of this
; license.
;
; THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
; WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
; TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
; PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
; IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
; CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
;
;********************************************************************/
.include "p24Hxxxx.inc"
.global _LoadAddr,_WriteMem,_WriteLatch,_ReadLatch,_ResetDevice,_Erase ;C called
_LoadAddr: ;W0=NVMADRU,W1=NVMADR - no return values
mov W0,TBLPAG
mov W1,W1
return
;***************************************************************
_WriteMem: ;W0=NVMCON - no return values
mov W0,NVMCON
mov #0x55,W0 ;Unlock sequence - interrupts need to be off
mov W0,NVMKEY
mov #0xAA,W0
mov W0,NVMKEY
bset NVMCON,#WR
nop ;Required
nop
1: btsc NVMCON,#WR ;Wait for write end
bra 1b
return
;***************************************************************
_WriteLatch: ;W0=TBLPAG,W1=Wn,W2=WordHi,W3=WordLo - no return values
mov W0,TBLPAG
tblwtl W3,[W1]
tblwth W2,[W1]
return
;***************************************************************
_ReadLatch: ;W0=TBLPAG,W1=Wn - data in W1:W0
mov W0,TBLPAG
tblrdl [W1],W0
tblrdh [W1],W1
return
;***************************************************************
_ResetDevice:
goto 0xc02
return
;***************************************************************
_Erase:
push TBLPAG
mov W2,NVMCON
mov w0,TBLPAG ; Init Pointer to page to be erased
tblwtl w1,[w1] ; Dummy write to select the row
mov #0x55,W0 ;Unlock sequence - interrupts need to be off
mov W0,NVMKEY
mov #0xAA,W0
mov W0,NVMKEY
bset NVMCON,#WR
nop ;Required
nop
erase_wait:
btsc NVMCON,#WR ;Wait for write end
bra erase_wait
pop TBLPAG
return
;***************************************************************
.end
)
for its PICmicro® Microcontroller is intended and
; supplied to you, the Company’s customer, for use solely and
; exclusively on Microchip PICmicro Microcontroller products. The
; software is owned by the Company and/or its supplier, and is
; protected under applicable copyright laws. All rights are reserved.
; Any use in violation of the foregoing restrictions may subject the
; user to criminal sanctions under applicable laws, as well as to
; civil liability for the breach of the terms and conditions of this
; license.
;
; THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
; WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
; TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
; PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
; IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
; CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
;
;********************************************************************/
.include "p24Hxxxx.inc"
.global _LoadAddr,_WriteMem,_WriteLatch,_ReadLatch,_ResetDevice,_Erase ;C called
_LoadAddr: ;W0=NVMADRU,W1=NVMADR - no return values
mov W0,TBLPAG
mov W1,W1
return
;***************************************************************
_WriteMem: ;W0=NVMCON - no return values
mov W0,NVMCON
mov #0x55,W0 ;Unlock sequence - interrupts need to be off
mov W0,NVMKEY
mov #0xAA,W0
mov W0,NVMKEY
bset NVMCON,#WR
nop ;Required
nop
1: btsc NVMCON,#WR ;Wait for write end
bra 1b
return
;***************************************************************
_WriteLatch: ;W0=TBLPAG,W1=Wn,W2=WordHi,W3=WordLo - no return values
mov W0,TBLPAG
tblwtl W3,[W1]
tblwth W2,[W1]
return
;***************************************************************
_ReadLatch: ;W0=TBLPAG,W1=Wn - data in W1:W0
mov W0,TBLPAG
tblrdl [W1],W0
tblrdh [W1],W1
return
;***************************************************************
_ResetDevice:
goto 0xc02
return
;***************************************************************
_Erase:
push TBLPAG
mov W2,NVMCON
mov w0,TBLPAG ; Init Pointer to page to be erased
tblwtl w1,[w1] ; Dummy write to select the row
mov #0x55,W0 ;Unlock sequence - interrupts need to be off
mov W0,NVMKEY
mov #0xAA,W0
mov W0,NVMKEY
bset NVMCON,#WR
nop ;Required
nop
erase_wait:
btsc NVMCON,#WR ;Wait for write end
bra erase_wait
pop TBLPAG
return
;***************************************************************
.end
Microcontroller is intended and
13 ; supplied to you, the Company’s customer,
for use solely and
14 ; exclusively on Microchip PICmicro Microcontroller products. The
15 ; software is owned by the Company and/or its supplier, and is
16 ;
protected under applicable copyright laws. All rights are reserved.
17 ; Any use in violation of the foregoing restrictions may subject the
18 ; user to criminal sanctions under applicable laws, as well as to
19 ; civil liability
for the breach of the terms and conditions of this
22 ; THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
; WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
; TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
; PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
; IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
; CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
;
;********************************************************************/
.include "p24Hxxxx.inc"
.global _LoadAddr,_WriteMem,_WriteLatch,_ReadLatch,_ResetDevice,_Erase ;C called
_LoadAddr: ;W0=NVMADRU,W1=NVMADR - no return values
mov W0,TBLPAG
mov W1,W1
return
;***************************************************************
_WriteMem: ;W0=NVMCON - no return values
mov W0,NVMCON
mov #0x55,W0 ;Unlock sequence - interrupts need to be off
mov W0,NVMKEY
mov #0xAA,W0
mov W0,NVMKEY
bset NVMCON,#WR
nop ;Required
nop
1: btsc NVMCON,#WR ;Wait for write end
bra 1b
return
;***************************************************************
_WriteLatch: ;W0=TBLPAG,W1=Wn,W2=WordHi,W3=WordLo - no return values
mov W0,TBLPAG
tblwtl W3,[W1]
tblwth W2,[W1]
return
;***************************************************************
_ReadLatch: ;W0=TBLPAG,W1=Wn - data in W1:W0
mov W0,TBLPAG
tblrdl [W1],W0
tblrdh [W1],W1
return
;***************************************************************
_ResetDevice:
goto 0xc02
return
;***************************************************************
_Erase:
push TBLPAG
mov W2,NVMCON
mov w0,TBLPAG ; Init Pointer to page to be erased
tblwtl w1,[w1] ; Dummy write to select the row
mov #0x55,W0 ;Unlock sequence - interrupts need to be off
mov W0,NVMKEY
mov #0xAA,W0
mov W0,NVMKEY
bset NVMCON,#WR
nop ;Required
nop
erase_wait:
btsc NVMCON,#WR ;Wait for write end
bra erase_wait
pop TBLPAG
return
;***************************************************************
.end
CONDITION. NO WARRANTIES,
23 ; WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
24 ; TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
25 ; PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
26 ; IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
27 ; CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
29 ;********************************************************************/
30 .include
"p24Hxxxx.inc"
32 .global _LoadAddr,_WriteMem,_WriteLatch,_ReadLatch,_ResetDevice,_Erase ;C called
35 _LoadAddr: ;W0=NVMADRU,W1=NVMADR - no
return values
41 ;***************************************************************
42 _WriteMem: ;W0=NVMCON - no
return values
44 mov #0x55,W0 ;Unlock sequence - interrupts need to be off
51 1: btsc NVMCON,#WR ;Wait
for write end
56 ;***************************************************************
57 _WriteLatch: ;W0=TBLPAG,W1=Wn,W2=WordHi,W3=WordLo - no
return values
64 ;***************************************************************
65 _ReadLatch: ;W0=TBLPAG,W1=Wn - data in W1:W0
73 ;***************************************************************
80 ;***************************************************************
87 mov w0,TBLPAG ; Init Pointer to page to be erased
88 tblwtl w1,[w1] ; Dummy
write to select the row
91 mov #0x55,W0 ;Unlock sequence - interrupts need to be off
100 btsc NVMCON,#WR ;Wait
for write end
106 ;***************************************************************