A
Alexander
I want to read and write the EEPROM of my PIC.
Unfortunatly, this doesn't work the way it's intended.
I want to call these functions to be called from an ISR and/or during normal
code execution.
I've added some code to restore the previous GIE state for this.
Could someone help me???
ThanX,
Alexander
WriteEE
MOVLW DATA_EE_ADDR ;
MOVWF EEADR ; Data Memory Address to read
MOVLW DATA_EE_DATA ;
MOVWF EEDATA ; Data Memory Value to write
BCF EECON1, EEPGD ; Point to DATA memory
BCF EECON1, CFGS ; Access program FLASH or Data EEPROM memory
BCF GIETEST ; Save current GIE state
BTFSC INTCON,GIE
BSF INTTEST,GIET
BCF INTCON, GIE ; Disable INTs.
BSF EECON1, WREN ; Enable Write
MOVLW 0x55 ;
MOVWF EECON2 ; 55h must be written to EECON2
MOVLW AAh ; to start write sequence
MOVWF EECON2 ; Write AAh
BSF EECON1,WR ; Set WR bit begin write
BTFSC GIETEST ; Restore GIE state
BSF INTCON,GIE ;
ReadEE ; Adress already in W returns
data in EEDATA
MOVWF EEADR ; Data Memory Address to read
BCF EECON1, EEPGD ; Point to DATA memory
BCF EECON1, CFGS ; Access program FLASH or Data EEPROM memory
BSF EECON1, RD ; EEPROM Read
Unfortunatly, this doesn't work the way it's intended.
I want to call these functions to be called from an ISR and/or during normal
code execution.
I've added some code to restore the previous GIE state for this.
Could someone help me???
ThanX,
Alexander
WriteEE
MOVLW DATA_EE_ADDR ;
MOVWF EEADR ; Data Memory Address to read
MOVLW DATA_EE_DATA ;
MOVWF EEDATA ; Data Memory Value to write
BCF EECON1, EEPGD ; Point to DATA memory
BCF EECON1, CFGS ; Access program FLASH or Data EEPROM memory
BCF GIETEST ; Save current GIE state
BTFSC INTCON,GIE
BSF INTTEST,GIET
BCF INTCON, GIE ; Disable INTs.
BSF EECON1, WREN ; Enable Write
MOVLW 0x55 ;
MOVWF EECON2 ; 55h must be written to EECON2
MOVLW AAh ; to start write sequence
MOVWF EECON2 ; Write AAh
BSF EECON1,WR ; Set WR bit begin write
BTFSC GIETEST ; Restore GIE state
BSF INTCON,GIE ;
ReadEE ; Adress already in W returns
data in EEDATA
MOVWF EEADR ; Data Memory Address to read
BCF EECON1, EEPGD ; Point to DATA memory
BCF EECON1, CFGS ; Access program FLASH or Data EEPROM memory
BSF EECON1, RD ; EEPROM Read