Flash von dsPIC33CK beschreiben Problem

Gast #6781697
Lesenswert?

Servus, ich möchte zum Test meinen PIC (dsPIC33CK256MP505) beschreiben. 
Ich habe die Datenblätter schon gewälzt werde aber in einer Sache nicht 
fündig. Wie beschreibe ich die "write latches" mit meinen Daten?
Zb im ersten Word mit AA BB CC und im zweiten mit DD EE FF

Hier ist mein Code

// ######
; Define the start address of the page to erase
.equ PROG_ADDR, 0x000400
; Set up the NVMADR registers to the starting address of the page
MOV #tblpage(PROG_ADDR),W0
MOV W0,NVMADRU
MOV #tbloffset(PROG_ADDR),W0
MOV W0,NVMADR
; Set up NVMCON to erase one page of Program Memory
MOV #0x4003,W0
MOV W0,NVMCON
; Disable interrupts < priority 7 for next 5 instructions

; Write the KEY Sequence
MOV #0x55,W0
MOV W0,NVMKEY
MOV #0xAA,W0
MOV W0,NVMKEY
; Start the erase operation
BSET NVMCON,#15
; Insert two NOPs after the erase cycle (required)
NOP
NOP

    // #######

    ; Define the address from where the programming has to start
.equ PROG_ADDR, 0x000400;
; Load the destination address to be written
MOV #tblpage(PROG_ADDR),W9
MOV #tbloffset(PROG_ADDR),W8
MOV W9,NVMADRU
MOV W8,NVMADR;
; Load the two words into the latches
CALL Load_Write_Latch_Word
; Setup NVMCON for word programming
MOV #0x4001,W0
MOV W0,NVMCON

; Write the key sequence
MOV #0x55,W0
MOV W0,NVMKEY
MOV #0xAA,W0
MOV W0,NVMKEY
; Start the write cycle
BSET NVMCON,#15
NOP
NOP


    wgaweg:  goto  wgaweg


    Load_Write_Latch_Word:
; W2 points to the address of the data to write to the latches

; Set up a pointer to the first latch location to be written
MOV #0xFA,W0
MOV W0,TBLPAG
MOV #0,W1
; Perform the TBLWT instructions to write the latches
TBLWTL [W2++],[W1]
TBLWTH [W2++],[W1++]
TBLWTL [W2++],[W1]
TBLWTH [W2++],[W1++]

    return
Gast #6781729
Lesenswert?

ok habs, falls es jmd interessiert:

So lade ich die Daten in eine speziefische RAM Adresse :

mov  #0xAAAA,W0
    mov  W0,0x2000
    mov  #0xBB,W0
    mov  W0,0x2002
    mov  #0xCCCC,W0
    mov  W0,0x2004
    mov  #0xDD,W0
    mov  W0,0x2006

und in Load_Write_Latch_Word dann noch folgende zeile am Anfang 
einfügen:

mov #0x2000,W2


MFG

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren