Habe Probleme den PIC eine Variable selbst schreiben zu lassen im Flash.
Er beschreibt zwar die richtigen Zellen, allerdings landet da nur
Datenmüll drin (Randomzahlen)
In meinem Test Code Adressiere ich die Zellen ab 0x22000 und schreibe
ein DWORD und 2 Bytes mit 0x66666 bzw. 0x66
Die Zellen sind frei und werden sonst nicht verwendet, eine
Unterbrechung der Routine durch Interrupts ist ebenfalls nicht gegeben
hier mein code:
1
mov #0x2000,W0 ;
2
mov W0,E_ZELLE
3
4
mov #0x6666,W0
5
mov W0,E_DATA
6
call WRITE_EE
7
8
WRITE_EE:
9
; Load the destination address to be written
10
MOV #0x2,W9
11
MOV E_ZELLE,W8
12
MOV W9,NVMADRU
13
MOV W8,NVMADR;
14
; Load the two words into the latches
15
MOV #0x6666,W2 ; 1. Word
16
MOV #0x66,W3
17
MOV #0x6666,W4 ; 2. Word
18
MOV #0x66,W5
19
20
TBLWTL W2, [W0]
21
TBLWTH W3, [W0++]
22
TBLWTL W4, [W0]
23
TBLWTH W5, [W0++]
24
; Setup NVMCON for word programming
25
MOV #0x4001,W0
26
MOV W0,NVMCON
27
; Disable interrupts < priority 7 for next 5 instructions
28
; Assumes no level 7 peripheral interrupts
29
DISI #06
30
; Write the key sequence
31
MOV #0x55,W0
32
MOV W0,NVMKEY
33
MOV #0xAA,W0
34
MOV W0,NVMKEY
35
; Start the write cycle
36
BSET NVMCON,#15
37
NOP
38
NOP
39
BTSC NVMCON, #15 ; Wait for the sequence to be completed