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

📄 flash.a51

📁 msc1201 编程3
💻 A51
字号:
$NOMOD51
$include (reg1210.inc)
PUBLIC	init_VonNeumann, _write_flash_byte ; ,cmd_parser
flash 	SEGMENT  CODE
			RSEG  flash
VonNeumann equ	08400h		; at UAM
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Init On-Chip VonNeumann SRAM
; Move the flash routines to 8400H
init_VonNeumann:
	orl	MCON,#1				; set RAMMAP bit
	mov	DPS,#1
	mov	dptr,#VonNeumann 	; mov source pointer
	mov	DPS,#0
	mov	dptr,#move_beg		; mov destination pointer
move_next:
	clr	a
	movc	a,@a+dptr			; get a source byte
	inc	dptr
	mov	DPS,#1
	movx	@dptr,a				; store to destination	
	inc	DPTR
	mov	DPS,#0
	mov	acc,DPL
	cjne	a,#LOW move_end, move_next
	mov	acc,DPH
	cjne	a,#HIGH move_end, move_next
	ret
move_beg:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Write a flash byte. faddr=R6:R7, fdata=R5. 
; void write_flash_byte(int faddr, char fdata)
; Used DPTR, A
wfb:
	MOV	DPH, R6
	MOV	DPL, R7
	MOV	A, R5
	;; Warning: Interrupt within this code segment will
	;;          crash the system.
	MOVX	@DPTR, A		; Data/Program Flash Write/Erase
wfb_wait:
	MOV 	A,FMCON		;flash busy bit
	JB		ACC.2, wfb_wait;
	RET
move_end: 
;	CSEG AT 0F97DH
;cmd_parser: 			; void cmd_parser(void);
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Write a flash byte. faddr=R6:R7, fdata=R5. 
; void write_flash_byte(int faddr, char fdata)
	CSEG AT 08400H
_write_flash_byte: 			
	end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -