读写24LCxx系列的EEPROM的实例程序
w_temp EQU 0x72
status_temp EQU 0x73
pclath_temp EQU 0x74
;
;***************************************
; ﹚竡 I2C ???の竲?
;
EEPROM_CMD equ 0xA0 ; Device adress of Slave Point
EE_Read equ .1
EE_Write equ .0
;
#define SCL PORTC,3 ; I2C SCL pin
#define SDA PORTC,4 ; I2C SDA pin
;
;********************************************
; Locates START($0.5760)up code @ the reset vector
;********************************************
Reset_Addr
org 0x00
nop
goto Main_Init
;
org 0x04
goto ISR
;
;*************************************************************
;**** The START($0.5760) Address of ISR is 0x004
;**** "PUSH" & "POP" ?ㄏノ絛ㄒ : 続ノ?钩 PIC16F877($4.6800) ΤSHARE BANK ?PIC
;**************************************************************
ISR
Push movwf w_temp ; save off current W register contents
movf STATUS,w ; move status register into W register
movwf status_temp ; save off contents of STATUS register
movf PCLATH,W
movwf pclath_temp
;
; Put your interrupt code here
;
Pop movf pclath_temp,W
movwf PCLATH
movf status_temp,w ; retrieve copy of STATUS register
movwf STATUS ; restore pre-isr STATUS register contents
swapf w_temp,f
swapf w_temp,w ; restore pre-isr W register contents
;
retfie ; return from interrupt
;----------------------------------------------------------------------
Main_Init
pagesel Init_I2C_Master ; Set PAGE to PCLATH Register
call Init_I2C_Master ; Init the MSSP for I2C Master
;
banksel I2C_Ctrl
movlw EEPROM_CMD ; Load EEPROM command address @ 0xA0
movwf I2C_Ctrl
;
;
Main
;
;----------------------------------------------------------------------
;
;* ???代刚祘&Alpha($5.2300);穦?盢?舱计?(0x40-0x47)糶??RMA0x40-0x47??竚
;* ?ノPage Write?よ&Alpha($5.2300);盢8??じ舱?戈?糶? EEPROM ?
;* 秈︽?篈?盎代EEPROM琌??ЧΘ糶??笆??程?盢?糶
;* ??戈??Sequential Read?よ&Alpha($5.2300);眖EEPROM弄?ㄓ??I2C_SEQU_Bufferい
;
Test_Page_RW
movlw 0x08
movwf I2C_Page_Length
movlw I2C_Page_Buffer
_Fill_RAM movwf FSR
movwf INDF
incf FSR,W
decfsz I2C_Page_Length,F
goto _Fill_RAM
;
Test_Page_Write
; banksel I2C_Ctrl
movlw EEPROM_CMD ; Load EEPROM command address @ 0xA0
movwf I2C_Ctrl
movlw 0x10 ; Select EEPROM location at 0x00
movwf I2C_Addr
movlw .8
movwf I2C_Page_Length
call EE_Page_Write
;
call EE_Ack_Check
;
banksel I2C_Ctrl
movlw EEPROM_CMD ; Load EEPROM command address @ 0xA0
movwf I2C_Ctrl
movlw 0x10
movwf I2C_Addr
movlw .8
movwf I2C_Page_Length
call EE_SEQU_Read
;
goto $
;
;---------------------------------------------------------
;
;* ???代刚祘&Alpha($5.2300);穦?糶????じ舱?戈?糶? EEPROM い
;* ?秈︽?篈?盎代琌??ЧΘ糶??笆??程?盢?糶
;* ??戈??眖EEPROM弄?ㄓ??I2C_Data既?竟い
;
Test_1byte_RW
EEPROM 相关文章:
- AT21CS01串行EEPROM与竞品的对比(10-09)
- DS33Z11/DS33Z44 EEPROM编程指南(09-23)
- Maxim带EEPROM高度集成PMIC MAX17106(02-16)
- DG128的EEPROM问题(02-14)
- 汽车常见EEPROM芯片有哪些?(02-19)
- EEPROM,EEPROM是什么意思(02-24)