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

How to Simulate AT89S8252 in {eeprom=2048} does it work !

Hello,

How to Simulate AT89S8252 in {eeprom=2048} does not work !
after setting {eeprom=2048} it shows eeprom but how do i read/write the eeprom since the standard routine does not work
I am using the following code which does not work but in real chip it works fine.

//
//***************************************************************************************************
//
unsigned char READ_EEPROM_89S8252(unsigned char volatile xdata *EEPROM_Address)
{
   WMCON |= 0x08;      //Set bit and do not clear othurs
   WMCON &= 0xef;      //Disable the bit
   while(!(WMCON & 2)); //while the bit is their
   return *EEPROM_Address; //Return address
}
//
//***************************************************************************************************
//
void WRITE_EEPROM_89S8252(unsigned char volatile xdata *EEPROM_Address,unsigned char DataToWrite)
{

   WMCON |= 0x18;      //Do the same as befor
   while(!(WMCON & 2)); //And here as well
   *EEPROM_Address = DataToWrite; //keep the line active
   WMCON &= 0xe7;      //Yes
   return;    //Exit the function
}


proton

  • Sorry,

    I think you should rephrase your post, because I cannot determine whether it is a question or a statement or a bit of both.

    But, I would suggest you consider the comments in your code.

    They probably meant something to you when ou wrote the code, but I have to say that I find most of them unrevealing!

       while(!(WMCON & 2)); //And here as well
    

    Wow.

  • I can only agree. The comments are bland, to say the least.

    "Set bit and do not clear othurs"
    Set what bit? Why set the bit?

    "Disable the bit"
    Disable what bit? Why disable bit?

    "while the bit is their"
    While what bit is there?
    Why wait while the unknown bit is there?

    "Return address"
    Are you really sure you are returning an address?

    "Do the same as befor"
    Do the same as what? And the same as where? And why?
    If you reference "the same as" another part of the code - how will you know that the other part does not get rewritten so you will no longer do the same?

    "And here as well"
    And here what as well? Disable an unnamed, unknown bit for an unknown reason? No need of a comment to know that. But does it help?

    "keep the line active"
    Keep what line active? And are you sure the write is there to keep any line active? In such case: how/why/when?

    "Yes"
    This one takes the price. Yes what? The line got through the compiler?

    "Exit the function"
    Are you explaining what your code does and why? Or are you explaining what the keyword does? I think the ISO standard has a better description of the return keyword. In what way does your comment improve upon the code? Is there a way that a normal programmer would not see the return, or would better understand that the standard return keyword actually leaves the function - just because you added a comment?

    I assume this is a school assignment. And somehow, somewhere you have been told that you should document your code and add comments. But a comment is only meaningful if it is meaningful. It must help. It must inform about something that isn't obvious from the actual code.

    And before you write a comment, you should take a closer look at the code. Can you rewrite the code so more of the information you want to put in the comment can be put into the code instead?

    Such as:

    MYDEV_CONTROLREG |= MYDEV_POWERED | MYDEV_ENABLED;
    while (MYDEV_CONTOLREG & MYDEV_BUSY) ;
    ...