This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem with AT89C51ED2 --EEPROM!

Hi Keil,

I have written the follwing code for writing the byte in EEPROM in ED2. The Problem is BUSY flag is not being cleared.

while(!(EECON & 0x01)) ;
EA = 0;
EECON |= 0x02;

XBYTE[0X0055] = 'C';

EECON |= OxOO;
EA = 1;

Please provide the suggesion.

Parents
  • hi,

    while(!(EECON & 0x01)) ;
    EA = 0;
    EECON |= 0x02;
    
    XBYTE[0X0055] = 'C';
    
    EECON |= OxOO;
    EA = 1;
    

    First of all, you should wait till EEBUSY has been set to zero. Your while() waits for the flag will be set to '1' -- that's wrong.
    Another issue is: to disconnect EEPROM you should use AND but your code shows OR.
    In sum:

    while(EECON & 0x01)
       ;
    EA = 0;
    EECON = 0x02;
    XBYTE[0X0055] = 'C';
    EECON = OxOO;
    EA = 1;
    


    If the code above is still not work please post assembly code generated by compiler.

    Regards,
    Oleg

Reply
  • hi,

    while(!(EECON & 0x01)) ;
    EA = 0;
    EECON |= 0x02;
    
    XBYTE[0X0055] = 'C';
    
    EECON |= OxOO;
    EA = 1;
    

    First of all, you should wait till EEBUSY has been set to zero. Your while() waits for the flag will be set to '1' -- that's wrong.
    Another issue is: to disconnect EEPROM you should use AND but your code shows OR.
    In sum:

    while(EECON & 0x01)
       ;
    EA = 0;
    EECON = 0x02;
    XBYTE[0X0055] = 'C';
    EECON = OxOO;
    EA = 1;
    


    If the code above is still not work please post assembly code generated by compiler.

    Regards,
    Oleg

Children
No data