Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Questions relating to using the EEPROM in the PICF877A

Status
Not open for further replies.

si2030

Member
Hi All,

I have been working on a function generator project and over the last day or so have been working specifically on reading and writing to the EEPROM.

My first question is, (see the picture) the EEPROM view shows the EEPROM with "FF" in every location. However when I run my code (stripped out of my larger project) it reads the EEPROM and places "00" in W... Either I am reading the EEPROM incorrectly or it actually has "00" in every register...

I have included my code as well. My intention is to read the first eight positions and load them into POS_1 to POS_10M (8 positions) and then check them to see if they actually have a value in one or more. I assumed they had "FF" and was simply subtracting "FF" and checking the STATUS register to see if it equaled zero... if they all equaled zero then nothing was loaded in the EEPROM..

Thing is I assumed by the EEPROM view that each unused register had "FF" was this incorrect? If not them why does it not load in "FF" from the EEPROM?

When I run the debugger and it goes to READ_EEPROM I end up with "0" IN W.....

Kind Regards

Simon

View attachment EEPROM.asm Capture.PNG
 
hi si,
Your EERead subr is wrong, look at this, I have not checked the rest of the code.

I have used movlw to address EEprom location 0x00 for test ONLY.

Code:
;*****************************************************************************
; Read contents of EEADR in W
;*****************************************************************************
READ_EPROM      
        bcf    STATUS,RP0
            bsf    STATUS,RP1     
        movlw 0x0
        movwf EEADR
        
        bsf STATUS,RP0
        bcf EECON1,EEPGD
    
            bsf     EECON1,RD    ;EEPROM READ

           bcf     STATUS,RP0     

        movf    EEDATA, W

          return
This is a single step thru of that subr, I preloaded the EEprom with 'E' 0x45
Code:
001F  0   MOVLW 0x27      000  27 '
0020  0   MOVWF FSR       000  27 '
0021  0   MOVLW 0x00      000  00 _
0022  0   MOVWF 0x039     000  00 _
0002  0   CALL 0x002      000  00 _
0003  0   BCF STATUS,RP0  000  00 _
0004  2   BSF STATUS,RP1  000  00 _
0005  2   MOVLW 0x00      000  00 _
0006  2   MOVWF EEADR     000  00 _
0007  3   BSF STATUS,RP0  000  00 _
0008  3   BCF EECON1,EEPGD000  00 _
0009  3   BSF EECON1,RD   000  00 _
000A  2   BCF STATUS,RP0  000  00 _
000B  2   MOVF EEDATA,W   000  45 E
0023  2   RETURN          000  45 E
 
Last edited:
Yet again Eric you come to the rescue... I then had a close look at the datasheet and yes there was a section on EEPROM..
 
Status
Not open for further replies.

Latest threads

Back
Top