⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fet110_flash_write.s43

📁 msp430p1110
💻 S43
字号:
#include  "msp430x11x.h"
;*****************************************************************************
;   MSP-FET430X110 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.
;
;                MSP430F1121
;             -----------------
;         /|\|              XIN|-  
;          | |                 | 
;          --|RST          XOUT|-
;            |                 |
;
#define     value  R4                    
;
;   M.Buccini
;   Texas Instruments, Inc
;   January 2002
;******************************************************************************
;------------------------------------------------------------------------------ 
            ORG     0F000h                  ; Program Start
;------------------------------------------------------------------------------ 
RESET       mov.w   #300h,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 + -