?? 實驗3_flash_write.s43
字號:
#include "msp430x44x.h"
;*****************************************************************************
; MSP-Test44x Demo - Flash In-System Programming Copy SegA to SegB
;
; Description; This program first erases flash seg A, then it increments all
; values in seg A, then it erases seg B, then copies seg A to seg B.
; Assumed MCLK 550kHz - 900kHz.
;
; MSP430F449
; -----------------
; /|\| XIN|-
; | | |
; --|RST XOUT|-
; | |
;
#define value R4
;------------------------------------------------------------------------------
ORG 01100h ; Program Start
;------------------------------------------------------------------------------
RESET mov.w #0A00h,SP ; Initialize stackpointer
StopWDT mov.w #WDTPW+WDTHOLD,&WDTCTL ; Stop WDT
clr.b value ; value = value to write to flash
;
Mainloop call #Write_SegA ; Copy value to segment A
inc.b value ;
call #CopyA2B ;
jmp Mainloop ; Repeat
;
;------------------------------------------------------------------------------
Write_SegA ;Input = value, holds value to write to Seg A, R5 used as working reg.
;------------------------------------------------------------------------------
mov.w #01080h,R5 ;
Timing mov.w #FWKEY+FSSEL0+FN0,&FCTL2 ; *Timing generator = MCLK/2
Erase_SegA mov.w #FWKEY,&FCTL3 ; Lock = 0
mov.w #FWKEY+ERASE,&FCTL1 ; Erase bit = 1
mov.w #0,&01080h ; Dummy write to SegA to erase
Prog_SegA mov.w #FWKEY+WRT,&FCTL1 ; Write bit = 1
Prog_L1 mov.b value,0(R5) ;
inc.w R5 ;
cmp.w #01100h,R5 ;
jne Prog_L1 ;
mov.w #FWKEY+LOCK,&FCTL3 ; Lock = 1
ret ;
;
;------------------------------------------------------------------------------
CopyA2B ;Copy Seg A to Seg B, R5 used as working reg.
;------------------------------------------------------------------------------
mov.w #FWKEY+FSSEL0+FN1,&FCTL2 ; *Timing generator = MCLK/3
Erase_SegB mov.w #FWKEY,&FCTL3 ; Lock = 0
mov.w #FWKEY+ERASE,&FCTL1 ; Erase bit = 1
mov.w #0,&01000h ; Dummy write to SegB to erase
mov.w #01080h,R5 ; R5 = First byte in Seg A
Prog_SegB mov.w #FWKEY+WRT,&FCTL1 ; Write bit = 1
Prog_L2 mov.b @R5+,-129(R5) ; Copy Seg A to Seg B
cmp.w #01100h,R5 ;
jne Prog_L2 ;
mov.w #FWKEY+LOCK,&FCTL3 ; Lock = 1
ret
;-----------------------------------------------------------------------------
; Interrupt Vectors Used MSP430F11x
;-----------------------------------------------------------------------------
ORG 0FFFEh ; MSP430 RESET Vector
DW RESET ;
END
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -