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 In simulating Read / Write procedures in eeprom of AT89C8252

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