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

EEPROM problem

I am using Temic 89C51RD2 microcontroller and I've tried to resolve
following problem for a long time. I have not any good ideas left, so I turn
to you. My problem is:
I'm using LARGE memory model. I try to program internal EEPROM with code
(only short part)

#pragma large
#include "D:/Keil/C51/inc/temic/89C51RD2.h" //added with EETIM and EECON
#define XBYTE ((unsigned char volatile xdata*) 0)
bit b;

EETIM = 0x37; //XTAL FREQ 11 MHz
EECON |= 0x02; //Enable EEPROM memory Set EEE bit
XBYTE [0x0000] = 0x02; //write data example
EECON = 0x52; //start programming
EECON = 0xA2; //...
do {
b = EECON & 0x01; //wait for EEBUSY-bit down -> programming done
}
while (b);

What's wrong. The program is always hanging in the programming phase. If I
use small memory model it won't hang. Reading from the EEPROM is also ok.

Parents
  • If it works in SMALL model, stay there. There's nothing you can't do in SMALL that you can do in LARGE. Just place your big data items in XDATA explicitly with the xdata keyword.

    In 12 years of 8051 development I have never used the large model, even when my code size is near 64K and I'm paging my XDATA around I use the small model. LARGE model is painfully inefficient and rarely required.

    BTW, the XBYTE macro can be replaced by:

    volatile unsigned char xdata eeprom _at_ 0x0000;
    eeprom = 0x02; // Write sample data
    - Mark

Reply
  • If it works in SMALL model, stay there. There's nothing you can't do in SMALL that you can do in LARGE. Just place your big data items in XDATA explicitly with the xdata keyword.

    In 12 years of 8051 development I have never used the large model, even when my code size is near 64K and I'm paging my XDATA around I use the small model. LARGE model is painfully inefficient and rarely required.

    BTW, the XBYTE macro can be replaced by:

    volatile unsigned char xdata eeprom _at_ 0x0000;
    eeprom = 0x02; // Write sample data
    - Mark

Children