程序如下,问题就是在读的过程是完全正常,但是写的时候看FLASH区的内容没有改变的啊,怎么回事啊,我什么都没有保护哦,是在SIM的条件下仿真。
#INCLUDE<P16F877A.INC>
__CONFIG B'11111101110010'
;bit13 1=code protection off
;bit12 read as 1
;bit11 1=in-circuit debugger mode off
;bit10,9 11=flash program memory write enable
;bit8 1=data eeprom code protection off
;bit7 0=RB3 as i/o pin lvp
;bit6 1=bor enable
;bit5,4 11=read as 11
;bit3 0=pwrt enable
;bit2 0=wdt off
;bit1,0 10=HS osc
TEMP EQU 20H
DATA1 EQU 21H
DATA2 EQU 22H
DATA3 EQU 23H
DATA4 EQU 24H
EADRL EQU 120H
EADRH EQU 121H
EDATAL EQU 122H
EDATAH EQU 123H
ORG 0000H
GOTO MAIN
ORG 0004H
GOTO DISPOSE_INT
ORG 0005H
;--------------------------
DISPOSE_INT
RETFIE
;--------------------------
PORT_INIT
CLRW
MOVWF INTCON
MOVWF PORTA
MOVWF PORTB
BSF STATUS,RP0
MOVWF TRISA
MOVWF TRISB
MOVLW 06H
MOVWF ADCON1
BCF STATUS,RP0
RETLW 0
;--------------------------
MAIN
CALL PORT_INIT
CLRW
MOVWF TEMP
BSF STATUS,RP1
MOVLW 00
MOVWF EADRL
FLASH_READ_START
CALL FLASH_READ
BSF STATUS,RP1
INCF EADRL,1
BCF STATUS,RP1
INCF TEMP,1
MOVLW 20H
SUBWF TEMP,0
BTFSS STATUS,Z
GOTO FLASH_READ_START
BSF STATUS,RP1
BCF STATUS,RP0
MOVLW 80H
MOVWF EADRL
MOVLW 30H
MOVWF EDATAL
BCF STATUS,RP1
MOVLW 00
MOVWF TEMP
FLASH_WRITE_START
CALL FLASH_WRITE
BSF STATUS,RP1
INCF EADRL,1
BCF STATUS,RP1
INCF TEMP,1
MOVLW 10H
SUBWF TEMP,0
BTFSS STATUS,Z
GOTO FLASH_WRITE_START
GOTO $
;--------------------------
FLASH_READ
BSF STATUS,RP0
BSF STATUS,RP1
FLASH_READ_WAIT
BTFSC EECON1,WR
GOTO $-1
BCF STATUS,RP0
MOVF EADRL,0
MOVWF EEADR
MOVF EADRH,0
MOVWF EEADRH
BSF STATUS,RP0
BSF EECON1,EEPGD
BSF EECON1,RD
NOP
NOP
BCF STATUS,RP0
MOVF EEDATA,0
MOVWF EDATAL
MOVF EEDATH,0
MOVWF EDATAH
BCF STATUS,RP1
RETLW 0
;-------------------------------
FLASH_WRITE
BSF STATUS,RP0
BSF STATUS,RP1
FLASH_WRITE_WAIT
BTFSC EECON1,WR
GOTO $-1
BCF STATUS,RP0
MOVF EADRL,0
MOVWF EEADR
MOVF EADRH,0
MOVWF EEADRH
MOVF EDATAL,0
MOVWF EEDATA
MOVF EDATAH,0
MOVWF EEDATH
BSF STATUS,RP0
BSF EECON1,EEPGD
BSF EECON1,WREN
MOVLW 55H
MOVWF EECON2
MOVLW 0AAH
MOVWF EECON2
BSF EECON1,WR
NOP
NOP
BCF STATUS,RP0
BCF STATUS,RP1
RETLW 0
END
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
其中2830是我写入的数据,不是一下就更新的,要等很久,不过指令倒是可以继续执行,纳闷!
一周热门 更多>