欢迎访问ic37.com |
会员登录 免费注册
发布采购

PIC16F873A-I/SP 参数 Datasheet PDF下载

PIC16F873A-I/SP图片预览
型号: PIC16F873A-I/SP
PDF下载: 下载PDF文件 查看货源
内容描述: 40分之28引脚增强型闪存微控制器 [28/40-pin Enhanced FLASH Microcontrollers]
分类和应用: 闪存微控制器和处理器外围集成电路光电二极管PC时钟
文件页数/大小: 222 页 / 3815 K
品牌: MICROCHIP [ MICROCHIP ]
 浏览型号PIC16F873A-I/SP的Datasheet PDF文件第31页浏览型号PIC16F873A-I/SP的Datasheet PDF文件第32页浏览型号PIC16F873A-I/SP的Datasheet PDF文件第33页浏览型号PIC16F873A-I/SP的Datasheet PDF文件第34页浏览型号PIC16F873A-I/SP的Datasheet PDF文件第36页浏览型号PIC16F873A-I/SP的Datasheet PDF文件第37页浏览型号PIC16F873A-I/SP的Datasheet PDF文件第38页浏览型号PIC16F873A-I/SP的Datasheet PDF文件第39页  
PIC16F87XA  
The steps to write to EEPROM data memory are:  
3.3  
Reading Data EEPROM Memory  
1. If step 10 is not implemented, check the WR bit  
to see if a write is in progress.  
To read a data memory location, the user must write the  
address to the EEADR register, clear the EEPGD con-  
trol bit (EECON1<7>), and then set control bit RD  
(EECON1<0>). The data is available in the very next  
cycle, in the EEDATA register; therefore, it can be read  
in the next instruction (see Example 3-1). EEDATA will  
hold this value until another read, or until it is written to  
by the user (during a write operation).  
2. Write the address to EEADR. Make sure that the  
address is not larger than the memory size of  
the device.  
3. Write the 8-bit data value to be programmed in  
the EEDATA register.  
4. Clear the EEPGD bit to point to EEPROM data  
memory.  
The steps to reading the EEPROM data memory are:  
5. Set the WREN bit to enable program operations.  
6. Disable interrupts (if enabled).  
1. Write the address to EEADR. Make sure that the  
address is not larger than the memory size of  
the device.  
7. Execute the special five instruction sequence:  
2. Clear the EEPGD bit to point to EEPROM data  
memory.  
• Write 55h to EECON2 in two steps (first to W,  
then to EECON2)  
3. Set the RD bit to start the read operation.  
4. Read the data from the EEDATA register.  
• Write AAh to EECON2 in two steps (first to W,  
then to EECON2)  
• Set the WR bit  
EXAMPLE 3-1:  
DATA EEPROM READ  
8. Enable interrupts (if using interrupts).  
BSF  
BCF  
MOVF  
MOVWF  
BSF  
STATUS,RP1  
STATUS,RP0  
DATA_EE_ADDR,W ; Data Memory  
EEADR  
STATUS,RP0  
EECON1,EEPGD  
;
9. Clear the WREN bit to disable program  
operations.  
; Bank 2  
10. At the completion of the write cycle, the WR bit  
is cleared and the EEIF interrupt flag bit is set.  
(EEIF must be cleared by firmware.) If step 1 is  
not implemented, then firmware should check  
for EEIF to be set, or WR to clear, to indicate the  
end of the program cycle.  
; Address to read  
; Bank 3  
; Point to Data  
; memory  
; EE Read  
; Bank 2  
BCF  
BSF  
BCF  
MOVF  
EECON1,RD  
STATUS,RP0  
EEDATA,W  
; W = EEDATA  
EXAMPLE 3-2:  
DATA EEPROM WRITE  
BSF  
BSF  
STATUS,RP1  
STATUS,RP0  
;
3.4  
Writing to Data EEPROM Memory  
BTFSC EECON,WR1  
;Wait for write  
;to complete  
;Bank 2  
To write an EEPROM data location, the user must first  
write the address to the EEADR register and the data to  
the EEDATA register. Then the user must follow a spe-  
cific write sequence to initiate the write for each byte.  
GOTO  
BCF  
$-1  
STATUS, RP0  
MOVF  
DATA_EE_ADDR,W ;Data Memory  
;Address to write  
DATA_EE_DATA,W ;Data Memory Value  
MOVWF EEADR  
MOVF  
MOVWF EEDATA  
The write will not initiate if the write sequence is not  
exactly followed (write 55h to EECON2, write AAh to  
EECON2, then set WR bit) for each byte. We strongly  
recommend that interrupts be disabled during this  
code segment (see Example 3-2).  
;to write  
;Bank 3  
;Point to DATA  
;memory  
;Enable writes  
BSF  
BCF  
STATUS,RP0  
EECON1,EEPGD  
EECON1,WREN  
INTCON,GIE  
BSF  
BCF  
Additionally, the WREN bit in EECON1 must be set to  
enable write. This mechanism prevents accidental  
writes to data EEPROM due to errant (unexpected)  
code execution (i.e., lost programs). The user should  
keep the WREN bit clear at all times, except when  
updating EEPROM. The WREN bit is not cleared  
by hardware  
;Disable INTs.  
;
;Write 55h  
;
;Write AAh  
;Set WR bit to  
;begin write  
;Enable INTs.  
;Disable writes  
MOVLW 55h  
MOVWF EECON2  
MOVLW AAh  
MOVWF EECON2  
BSF  
EECON1,WR  
BSF  
BCF  
INTCON,GIE  
EECON1,WREN  
After a write sequence has been initiated, clearing the  
WREN bit will not affect this write cycle. The WR bit will  
be inhibited from being set unless the WREN bit is set.  
At the completion of the write cycle, the WR bit is  
cleared in hardware and the EE Write Complete  
Interrupt Flag bit (EEIF) is set. The user can either  
enable this interrupt or poll this bit. EEIF must be  
cleared by software.  
2001 Microchip Technology Inc.  
Advance Information  
DS39582A-page 33