Texas Instruments MSP430x1xx Computer Hardware User Manual


 
Flash Memory Operation
5-10
Flash Memory Controller
Initiating a Byte/Word Write from RAM
The flow to initiate a byte/word write from RAM is shown in Figure 5−9.
Figure 5−9. Initiating a Byte/Word Write from RAM
yes
BUSY = 1
yes
BUSY = 1
Disable all interrupts and watchdog
Setup flash controller
and set WRT=1
Write byte or word
Set WRT=0, LOCK = 1
re-enable interrupts and watchdog
; Byte/word write from RAM. 514 kHz < SMCLK < 952 kHz
; Assumes 0FF1Eh is already erased
; Assumes ACCVIE = NMIIE = OFIE = 0.
MOV #WDTPW+WDTHOLD,&WDTCTL ; Disable WDT
DINT ; Disable interrupts
L1 BIT #BUSY,&FCTL3 ; Test BUSY
JNZ L1 ; Loop while busy
MOV #FWKEY+FSSEL1+FN0,&FCTL2 ; SMCLK/2
MOV #FWKEY,&FCTL3 ; Clear LOCK
MOV #FWKEY+WRT,&FCTL1 ; Enable write
MOV #0123h,&0FF1Eh ; 0123h −> 0FF1Eh
L2 BIT #BUSY,&FCTL3 ; Test BUSY
JNZ L2 ; Loop while busy
MOV #FWKEY,&FCTL1 ; Clear WRT
MOV #FWKEY+LOCK,&FCTL3 ; Set LOCK
... ; Re-enable WDT?
EINT ; Enable interrupts