英锐恩单片机论坛,Microchip单片机,模拟器件,接口电路,麦肯单片机,单片机应用交流
标题:
片内flash读写
[打印本页]
作者:
lucky
时间:
2012-8-20 15:59
标题:
片内flash读写
在对flash的读写操作时发现那句WR或者rd置1的语句没能执行,eeif标志位没变。不知还有什么要设置的?试过了,读写E2PROM没有问题,能对其置1.期待大侠指点,谢谢
LIST P=16F877,R=DEC
#include <p16F877.inc>
count = 21H
addrl equ 76H
addrh equ 77H
datal equ 78h
datah equ 79h
e_addrl equ 176H
e_addrh equ 177H
e_data equ 178H
e_datah equ 179H
org 000h
main
movlw 05h
movwf addrl
movlw 07h
movwf addrh
movlw 08h
movwf datal
movlw 08h
movwf datah
BSF STATUS, RP1 ;
BSF STATUS, RP0 ;Bank 3
BCF STATUS, RP0 ;Bank 2
movf e_addrl,0
movwf EEADR ; 存入数据的E2PROM地址
movf e_addrh,0
movwf EEADRH ; 存入数据的E2PROM地址
movf e_datah,0
movwf EEDATH ; 存入E2PROM的数据
movf e_data,0
movwf EEDATA ; 存入E2PROM的数据
BSF STATUS, RP0 ;Bank 3
BSF EECON1, EEPGD
oint to Data memory
BSF EECON1, WREN ;Enable writes
;Only disable interrupts
BCF INTCON, GIE ;if already enabled,
;otherwise discard
MOVLW 0x55 ;Write 55h to
MOVWF EECON2 ;EECON2
MOVLW 0xAA ;Write AAh to
MOVWF EECON2 ;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
欢迎光临 英锐恩单片机论坛,Microchip单片机,模拟器件,接口电路,麦肯单片机,单片机应用交流 (http://enroobbs.com/)
Powered by Discuz! X3.2