Texas Instruments MSP430x1xx User Manual page 143

Texas instruments modules and peripherals user's guide
Table of Contents

Advertisement

; Write one block starting at 0F000h.
; Must be executed from RAM, Assumes Flash is already erased.
;
514 kHz < SMCLK < 952 kHz
; Assumes ACCVIE = NMIIE = OFIE = 0.
MOV
#32,R5
MOV
#0F000h,R6
MOV
#WDTPW+WDTHOLD,&WDTCTL
DINT
L1 BIT
#BUSY,&FCTL3
JNZ
L1
MOV
#FWKEY+FSSEL1+FN0,&FCTL2 ; SMCLK/2
MOV
#FWKEY,&FCTL3
MOV
#FWKEY+BLKWRT+WRT,&FCTL1
L2 MOV
Write_Value,0(R6)
L3 BIT
#WAIT,&FCTL3
JZ
L3
INCD
R6
DEC
R5
JNZ
L2
MOV
#FWKEY,&FCTL1
L4 BIT
#BUSY,&FCTL3
JNZ
L4
MOV
#FWKEY+LOCK,&FCTL3
...
EINT
Flash Memory Operation
; Use as write counter
; Write pointer
; Disable WDT
; Disable interrupts
; Test BUSY
; Loop while busy
; Clear LOCK
; Enable block write
; Write location
; Test WAIT
; Loop while WAIT=0
; Point to next word
; Decrement write counter
; End of block?
; Clear WRT,BLKWRT
; Test BUSY
; Loop while busy
; Set LOCK
; Re-enable WDT if needed
; Enable interrupts
Flash Memory Controller
5-13

Advertisement

Table of Contents
loading

Table of Contents