Hi , 1. I have used these code samples ( URL: http://www.keil.com/support/docs/2369.htm) in order to read and write from eeprom on chip AT89C8252 (I Only done it with the debbuger simulation and not with the chip itslef ) =========================================== *********************************************************************************** include <AT898252.H> #include <absacc.h> /* * Return EEPROM Byte at address 'adr' */ unsigned char ReadEEPROM (unsigned int adr) { unsigned char v; WMCON |= EEMEN_; // enable EEPROM v = XBYTE[adr]; // read value WMCON &= ~EEMEN_; // disable EEPROM return (v); } /* * Write EEPROM Byte 'val' at address 'adr' */ void WriteEEPROM (unsigned int adr, unsigned char val) { WMCON |= (EEMEN_ | EEMWE_); // enable EEPROM and set write bit XBYTE[adr] = val; // write value while ((WMCON & EERDY_) == 0); // wait until value programmed WMCON &= ~(EEMWE_ | EEMEN_); // disable EEPROM and write strobe } unsigned char v; void main (void) { v = ReadEEPROM (0x200); // read EEPROM address 0x200 WriteEEPROM (0x200, 6); // write 6 to EEPROM address 0x200 while (1); } ******************************************************************************************END OF SAMPLE 2. my problem: the writeEEPROM procedure fails by getting stucked in the line: " while ((WMCON & EERDY_) == 0); " 3. I beleive it happens because the WMCON flag is not 4. Is the debbuger cannot simulate this ???? is there any other reason for the write EEPROM failures ? Thanx in advance Daniel
I just tried the same example and it works just fine. The write cycle for EEPROM takes a long time nd maybe you are not waiting long enough. According to the Data Sheet, "EEPROM write cycles in the serial programming mode are self-timed and ypically take 2.5 ms." I set a breakpoint on the line of code after the while ((WMCON & EERDY_) == 0); and the simulator stops on that line about 5000 states later (2500 uSec or 2.5mSec) like the data sheet states. Jon
Hi Jon , Thanx for the reply. Which Version did U use ? Did U used the compiler simulation or the real device ? Thanx alot
Which Version did U use ? V7.01 Did U used the compiler simulation or the real device ? Simulation. Jon