fet140_flash_write.s43
来自「基于IAR Workbench for MSP430 的汇编语言例程」· S43 代码 · 共 71 行
S43
71 行
;*****************************************************************************
; MSP-FET430P140 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.
;
; MSP430F149
; -----------------
; /|\| XIN|-
; | | |
; --|RST XOUT|-
; | |
;
#define value R4
;
; M.Buccini
; Texas Instruments, Inc
; January 2004
;******************************************************************************
#include "msp430x14x.h"
;------------------------------------------------------------------------------
ORG 01100h ; Progam Start
;------------------------------------------------------------------------------
RESET mov.w #0A00h,SP ; Initialize 'F1x9 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 MSP430x13x/14x/15x/16x
;-----------------------------------------------------------------------------
ORG 0FFFEh ; MSP430 RESET Vector
DW RESET ;
END
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?