Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
MOVLW CODE_ADDR_UPPER ; load TBLPTR with the base
MOVWF TBLPTRU ; address of the memory block
MOVLW CODE_ADDR_HIGH
MOVWF TBLPTRH
MOVLW CODE_ADDR_LOW
MOVWF TBLPTRL
ERASE_ROW
BSF EECON1, EEPGD ; point to FLASH program memory
BSF EECON1, WREN ; enable write to memory
BSF EECON1, FREE ; enable Row Erase operation
BCF INTCON, GIE ; disable interrupts
MOVLW 55h
MOVWF EECON2 ; write 55H
Required MOVLW AAh
Sequence MOVWF EECON2 ; write AAH
BSF EECON1, WR ; start erase (CPU stall)
NOP
BSF INTCON, GIE ; re-enable interrupts
Hi, can anyone tell me how do we write to the internal eeprom of a PIC microcontroller.For external we use TABLWT but what about the internal EEPROM.
; ***************************************************************************
; Read EEPROM Address 0x00 and copy to counter variable
; ***************************************************************************
ReadEE
movlw 0x00 ; Address in EEPROM
movwf EEADR ; Data Memory Address to read
bcf EECON1, EEPGD ; Point to DATA memory
bcf EECON1, CFGS ; Access EEPROM
bsf EECON1, RD ; EEPROM Read
movff EEDATA, counter ; EEDATA --> Counter
retlw 0x00
; ***************************************************************************
; Write value of variable counter into EEPROM address 0x00
***************************************************************************
WriteEE
movlw 0x00 ; Address
movwf EEADR ; Data Memory Address to write
movf counter,W;
movwf EEDATA ; Data Memory Value to write
bcf EECON1, EEPGD ; Point to DATA memory
bcf EECON1, CFGS ; Access EEPROM
bsf EECON1, WREN ; Enable writes
bcf INTCON, GIE ; Disable Interrupts
movlw 55h ;
movwf EECON2 ; Write 55h
movlw 0AAh
movwf EECON2 ; Write 0AAh
bsf EECON1, WR ; Set WR bit to begin write
bsf INTCON, GIE ; Enable Interrupts
Eeloop btfss PIR2,EEIF ; Is int bit on ie WRTDONE
bra Eeloop ; continue
bcf PIR2,EEIF ; reset interupt
bcf EECON1, WREN ; Disable writes on write complete (EEIF set)