+ Post New Thread
Results 1 to 3 of 3
  1. #1
    Member level 5
    Points: 1,960, Level: 10

    Join Date
    Mar 2010
    Location
    mashhad
    Posts
    86
    Helped
    26 / 26
    Points
    1,960
    Level
    10

    My EEPROM read function does not work on 16F876A internal EEPROM?

    Hi to all (Salam)
    I want to read from internal EEPROM of a PIC16F876A.
    I wrote a function for read and also a function to write.
    The write function works fine but the read function does not work.
    these are my functions (In mikroC PRO):
    //---------Read EEPROM--------//
    char ReadEEPROM(char EEReadAddress)
    {
    EEADR=EEReadAddress;
    EEPGD_bit=0;
    RD_bit=0;
    asm nop;
    return(EEDATA);
    }
    //--------Write EEPROM--------//
    void WriteEEPROM(char EEWriteAddress, char EEPROMData)
    {
    EEADR=EEWriteAddress;
    EEDATA=EEPROMData;
    EEPGD_bit=0;
    WREN_bit=1;
    EECON2=0x55;
    EECON2=0xAA;
    WR_bit=1;
    WREN_bit=0;
    while(WR_bit)
    {
    asm nop;
    }
    }
    I wrote these function just like PIC16F87xA data sheet.
    I also debug it with Proteus. in read function EEADR always filled with 0xA1 not with EEReadAddress.:?

    •   AltAdvertisment

        
       

  2. #2
    Advanced Member level 5
    Points: 16,636, Level: 31

    Join Date
    Jul 2001
    Location
    Oberon
    Posts
    1,897
    Helped
    442 / 442
    Points
    16,636
    Level
    31

    Re: My EEPROM read function does not work on 16F876A internal EEPROM?

    The RD bit should be set to initiate the read.


    1 members found this post helpful.

    •   AltAdvertisment

        
       

  3. #3
    Member level 5
    Points: 1,960, Level: 10

    Join Date
    Mar 2010
    Location
    mashhad
    Posts
    86
    Helped
    26 / 26
    Points
    1,960
    Level
    10

    Re: My EEPROM read function does not work on 16F876A internal EEPROM?

    Opps! a little bug with big bad result!
    I change my code. read function also works fine, but in Proteus EEADR always have 0xA1?
    (Thank you very much).

    ---------- Post added at 18:00 ---------- Previous post was at 17:54 ----------

    My problem solved totally.
    thanks a lot.



--[[ ]]--