📄 669iaplib.a51
字号:
POP IE ; restore interrupts to initial state
ERET
; end of iap_program_data_byte
; **********************************************************************
; function: iap_read_data_byte
; prototype: unsigned char iap_read_data_byte
; (unsigned int addr, unsigned char seg);
; description: reads a byte from the flash. passed is the 16-bit
; address and 64k segment
; **********************************************************************
RSEG ?PR?_iap_read_data_byte?P669IAPLIB
_iap_read_data_byte:
PUSH IE ; disable interrupts
CLR EA
MOV A,CMOD
MOV R2,A ; store copy of CMOD
JNB ACC.6,?IAPTAG12 ; if watchdog enabled then disable
ANL CMOD,#0BFH
?IAPTAG12:
ORL AUXR1,#020H ; enable bootrom
MOV R1,#03H
MOV EPH,R5 ; address to program
MOV EPM,R6
MOV EPL,R7
LCALL 00FFF0H ; call iap routine
MOV R7,A ; result in accumulator
ANL AUXR1,#0DFH ; disable bootrom
MOV CMOD,R2 ; restore CMOD (restore watchdog state)
POP IE ; restore interrupts to initial state
ERET
; end of iap_read_data_byte
; **********************************************************************
; function: iap_erase_block
; prototype: unsigned char iap_erase_block(unsigned int block);
; description: erases a block of flash. passed is a number indicating
; the block to erase. returns zero for success, non-zero for failure
; **********************************************************************
RSEG ?PR?_iap_erase_block?P669IAPLIB
_iap_erase_block:
PUSH IE ; disable interrupts
CLR EA
MOV A,CMOD
MOV R2,A ; store copy of CMOD
JNB ACC.6,?IAPTAG13 ; if watchdog enabled then disable
ANL CMOD,#0BFH
?IAPTAG13:
ORL AUXR1,#020H ; enable bootrom
MOV R1,#0CH
MOV EPH,R6 ; address to program
MOV EPM,R7
LCALL 00FFF0H ; call iap routine
MOV R7,A ; result in accumulator
ANL AUXR1,#0DFH ; disable bootrom
MOV CMOD,R2 ; restore CMOD (restore watchdog state)
POP IE ; restore interrupts to initial state
ERET
; end of iap_erase_block
; **********************************************************************
; function: iap_read_boot_vector
; prototype: unsigned int iap_read_boot_vector(void);
; description: returns the byte stored in the boot vector
; **********************************************************************
RSEG ?PR?iap_read_boot_vector?P669IAPLIB
iap_read_boot_vector:
PUSH IE ; disable interrupts
CLR EA
MOV A,CMOD
MOV R2,A ; store copy of CMOD
JNB ACC.6,?IAPTAG14 ; if watchdog enabled then disable
ANL CMOD,#0BFH
?IAPTAG14:
ORL AUXR1,#020H ; enable bootrom
MOV R1,#07H
MOV EPL,#01H
LCALL 00FFF0H ; call iap routine
MOV R7,A ; result returned in R7
MOV R1,#07H
MOV EPL,#02H
LCALL 00FFF0H ; call iap routine
MOV R6,A ; result returned in R6
ANL AUXR1,#0DFH ; disable bootrom
MOV CMOD,R2 ; restore CMOD (restore watchdog state)
POP IE ; restore interrupts to initial state
ERET
; end of iap_read_boot_vector
; **********************************************************************
; function: iap_read_status_byte
; prototype: unsigned char iap_read_status_byte(void);
; description: returns the value of the status byte
; **********************************************************************
RSEG ?PR?iap_read_status_byte?P669IAPLIB
iap_read_status_byte:
PUSH IE ; disable interrupts
CLR EA
MOV A,CMOD
MOV R2,A ; store copy of CMOD
JNB ACC.6,?IAPTAG15 ; if watchdog enabled then disable
ANL CMOD,#0BFH
?IAPTAG15:
ORL AUXR1,#020H ; enable bootrom
MOV R1,#07H
MOV EPL,#00H
LCALL 00FFF0H ; call iap routine
MOV R7,A ; result returned in R7
ANL AUXR1,#0DFH ; disable bootrom
MOV CMOD,R2 ; restore CMOD (restore watchdog state)
POP IE ; restore interrupts to initial state
ERET
; end of iap_read_status_byte
; **********************************************************************
; function: iap_erase_bv_sb
; prototype: unsigned char iap_erase_bv_sb(void);
; description: erases the boot vector and status byte
; returns zero for success, non-zero for failure
; **********************************************************************
RSEG ?PR?iap_erase_bv_sb?P669IAPLIB
iap_erase_bv_sb:
PUSH IE ; disable interrupts
CLR EA
MOV A,CMOD
MOV R2,A ; store copy of CMOD
JNB ACC.6,?IAPTAG16 ; if watchdog enabled then disable
ANL CMOD,#0BFH
?IAPTAG16:
ORL AUXR1,#020H ; enable bootrom
MOV R1,#04H
LCALL 00FFF0H ; call iap routine
MOV R7,A ; result returned in R7
ANL AUXR1,#0DFH ; disable bootrom
MOV CMOD,R2 ; restore CMOD (restore watchdog state)
POP IE ; restore interrupts to initial state
ERET
; end of iap_erase_bv_sb
; **********************************************************************
; function: iap_program_status_byte
; prototype: void iap_program_status_byte(unsigned char status_byte);
; description: programs the status byte
; returns zero for success, non-zero for failure
; **********************************************************************
RSEG ?PR?_iap_program_status_byte?P669IAPLIB
_iap_program_status_byte:
PUSH IE ; disable interrupts
CLR EA
MOV A,CMOD
MOV R2,A ; store copy of CMOD
JNB ACC.6,?IAPTAG17 ; if watchdog enabled then disable
ANL CMOD,#0BFH
?IAPTAG17:
ORL AUXR1,#020H ; enable bootrom
MOV R1,#06H
MOV EPL,#00H
MOV A,R7 ; new value to program
LCALL 00FFF0H ; call iap routine
MOV R7,A ; result returned in R7
ANL AUXR1,#0DFH ; disable bootrom
MOV CMOD,R2 ; restore CMOD (restore watchdog state)
POP IE ; restore interrupts to initial state
ERET
; end of iap_program_status_byte
; **********************************************************************
; function: iap_program_boot_vector
; prototype: void iap_program_boot_vector(unsigned int boot_vector);
; description: programs the boot vector
; returns zero for success, non-zero for failure
; **********************************************************************
RSEG ?PR?_iap_program_boot_vector?P669IAPLIB
_iap_program_boot_vector:
PUSH IE ; disable interrupts
CLR EA
MOV A,CMOD
MOV R2,A ; store copy of CMOD
JNB ACC.6,?IAPTAG18 ; if watchdog enabled then disable
ANL CMOD,#0BFH
?IAPTAG18:
ORL AUXR1,#020H ; enable bootrom
MOV R1,#06H
MOV EPL,#01H
MOV A,R7 ; new value to program
LCALL 00FFF0H ; call iap routine
MOV R1,#06H
MOV EPL,#02H
MOV A,R6 ; new value to program
LCALL 00FFF0H ; call iap routine
MOV R7,A ; result returned in R7
ANL AUXR1,#0DFH ; disable bootrom
MOV CMOD,R2 ; restore CMOD (restore watchdog state)
POP IE ; restore interrupts to initial state
ERET
; end of iap_program_boot_vector
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -