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.
when I switch it over from the EEPROM register to the W register to work with it, it pops
I could be reading from the wrong bank indeed. I'm reading the value from EEPROM, and when I switch it over from the EEPROM register to the W register to work with it, it pops.
read
banksel EEADR
movf NEW, W ;
movwf EEADR ; Data Memory Address to read
banksel EECON1
bcf EECON1, EEPGD; Point to Data memory
bsf EECON1, RD ; EE Read
banksel EEDATA ; Select Bank of EEDATA
movf EEDATA, W ; W = EEDATA
return
write
banksel EECON1 ; Select Bank of EECON1
btfsc EECON1, WR ; Wait for write
goto $-1 ; to complete
banksel EEADR ; Select Bank of EEADR
movf NEW, W ;
movwf EEADR ; Data Memory Address to write
movf NEW, W ;
movwf EEDATA ; Data Memory Value to write
banksel EECON1 ; Select Bank of EECON1
bcf EECON1, EEPGD ; Point to DATA memory
bsf EECON1, WREN ; Enable writes
bcf INTCON, GIE ; Disable INTs.
movlw h'55' ;
movwf EECON2 ; Write 55h
movlw h'AA' ;
movwf EECON2 ; Write AAh
bsf EECON1, WR ; Set WR bit to begin write
bsf INTCON, GIE ; Enable INTs.
bcf EECON1, WREN ; Disable writes
return ;
;coming from A/D going to EEPROM
swapf ADRESH
movlw B'00001111'
andwf ADRESH
rrf ADRESH
movfw ADRESH
movwf NEW