Texas Instruments MSP430x1xx User Manual

Page 437

Advertising
background image

Flash Memory Access via JTAG and Software

C-25

Flash Memory

C.5.3.3 Example, Programming Byte Sequences Into a Flash Memory Module via Software

Sequences of data, bytes, or words can use the segment-write feature. This
reduces the programming time by about one half.

yes

no

no

yes

Set Pointer for Start and End

Clear Lock Bit

SEG WRT = WRT =0

End of Segment Write

no

yes

Fxkey .set 03300h
Fwkey .set 0A500h
Frkey .set 09600h

Test_Busy1

BIT

JNZ

#BUSY,&FCTL3

; Flash busy? SEGWRT ended?

Test_Busy1

MOV

#(Fwkey+WRT+SEGWRT),&FCTL1

; Segment write

Test_WAIT1

RAM2FLASH

MOV

#Start_Ptr,Rx

MOV

#End_Ptr,Ry

MOV

#Fkey,&FCTL3

CMP

Rx,Ry

; All data programmed?

JZ

End_Seg_Write

MOV.B

@Rx+,(Flash_Start_Ptr–Start_ptr–1) (Rx)

; Program data: in this example one byte

BIT

#03Fh,Rx

JNZ

Test_Wait1

; Segment border?

Test_Wait2

BIT

#WAIT,&FCTL3

; Test if data written

JZ

Test_Wait2

MOV

#Fwkey,&FCTL1

; Stop segment write

JMP

Test_busy1

; Segment write ends if busy=0

End_Seg_Write

; All data are programmed

MOV

#Fwkey,&FCTL1

; Stop segment write

Test_Busy2

BIT

#BUSY,&FCTL3

; Segment write ended?

JNZ

Test_Busy2

XOR

#(Fxkey+Lock),&FCTL3

; Change Lock bit to ’1

; Ensure that neither Watchdog Timer, nor
; interrupts nor Low–Power Modes may corrupt
; proper execution

yes

no

Busy ?

SEG WRT = WRT =1

BIT

JNE

#WAIT,&FCTL3

Test_WAIT1

; Clear lock bit

WAIT = 1

Write Byte to Flash

Segment

border?

yes

no

WAIT = 1

Busy ?

yes

no

SEG WRT = WRT =0

All data

Programmed?

Advertising