片内flash读写
在对flash的读写操作时发现那句WR或者rd置1的语句没能执行,eeif标志位没变。不知还有什么要设置的?试过了,读写E2PROM没有问题,能对其置1.期待大侠指点,谢谢LIST P=16F877,R=DEC
#include <p16F877.inc>
count = 21H
addrl equ76H
addrh equ77H
datal equ78h
datah equ79h
e_addrlequ176H
e_addrhequ177H
e_dataequ178H
e_datahequ179H
org 000h
main
movlw05h
movwfaddrl
movlw07h
movwfaddrh
movlw08h
movwfdatal
movlw08h
movwfdatah
BSF STATUS, RP1 ;
BSF STATUS, RP0 ;Bank 3
BCF STATUS, RP0 ;Bank 2
movfe_addrl,0
movwf EEADR ; 存入数据的E2PROM地址
movfe_addrh,0
movwf EEADRH ; 存入数据的E2PROM地址
movfe_datah,0
movwf EEDATH ; 存入E2PROM的数据
movfe_data,0
movwf EEDATA ; 存入E2PROM的数据
BSF STATUS, RP0 ;Bank 3
BSF EECON1, EEPGD ;Point to Data memory
BSF EECON1, WREN;Enable writes
;Only disable interrupts
BCF INTCON, GIE ;if already enabled,
;otherwise discard
MOVLW0x55 ;Write 55h to
MOVWFEECON2 ;EECON2
MOVLW0xAA ;Write AAh to
MOVWFEECON2 ;EECON2
BSF EECON1, WR ;Start write operation
;Only enable interrupts
NOP
NOP
BSF INTCON, GIE ;if using interrupts,
;otherwise discard
BCF EECON1, WREN;Disable writes
goto $
S
end
页:
[1]