-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmemory.s
83 lines (66 loc) · 2.34 KB
/
memory.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
;********************************************************************
; FileName: memory.s
; Dependencies:
; Processor: dsPIC30F Family
; Hardware: dsPICDEM 2
; Assembler: ASM30 2.14
; Company: Microchip Technology, Inc.
;
; Software License Agreement
;
; The software supplied herewith by Microchip Technology Incorporated
; (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 "p30fxxxx.inc"
.global _LoadAddr,_WriteMem,_WriteLatch,_ReadLatch,_ResetDevice ;C called
_LoadAddr: ;W0=NVMADRU,W1=NVMADR - no return values
mov W0,NVMADRU
mov W1,NVMADR
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 0x700
return
.end
;***************************************************************