Electronic – Writing data on EEPROM or Flash memory of the PIC18F47J53

eepromflashmemorypic

So I am using the 18F47J53 in Hitech PICC18-PRO compiler with MPLAB-X IDE, and for some reason there happens to be absolutely no support for the reading/writing function to either the flash or the EEPROM. All I need to do is write a received mobile telephone number that is read from a GSM module when receiving an SMS. Then later recall this number for comparison.

It seems as though it should be a really simple procedure using on of the predefined commands such as "eeprom_write(unsigned int address,unsigned char data);", though after checking why I get an error, I see that these commands are not supported, and even the basic standard command "EEPROM_WRITE(addr, data)" which does compile, does not do anything as it was "Added only for code portability", and the functions have been commented out.

Does this mean that this processor does not support any sort of internal read/write functionality, or has it just never been defined.

I have started manually (bit-wise) writing read/write/erase functions for this though without proper addressing could cause some major run time errors, especially due to the fact that the erase function can only work in blocks of 1024 bytes.

The write function looks something like this:

while(WR != 0){;}   // wait till EEPROM idle

    /* Load Table pointer Reg with Write to address (previously block erased) */
    TBLPTRU = Code_Addr_Upper;  // Load TBLPTR with Base Addresses?
    TBLPTRH = Code_Addr_High;   // Load TBLPTR with Base Addresses?
    TBLPTRL = Code_Addr_Low;    // Must be EVEN Addresses?

do{
       GIE = 0;                 /* disable interrupts */
    }while(GIE != 0);           /* make sure it worked */

WREN=1;                     /* enable writes */
EECON2=0x55;                // required sequence for EEPROM update
EECON2=0xAA;

do{
       WR = 1;                  /* disable interrupts */
    }while(WR != 1);            /* make sure it worked */

    WREN=0;                     /* Disable writes */
GIE=1;                      // re-enable interrupts

which receives 2 bytes at a time as the datasheet states that the smallest write size is 1 word at a time.

Has anyone found a way around this? Surely there is a simpler way.

Any help would be greatly appreciated.

Best Answer

The PIC18F47J53 doesn't have EEPROM memory.

As for Flash programming, I don't believe there's a simpler way to write to it than the one you tried. You just have to be careful not to write/erase an already used memory section.