EmbeddedRelated.com
Forums

PIC18f452 Program Memory Problem

Started by GaryI August 18, 2008
Hi,

I've got a bootloader for the pic18f - The following function is ok
for the pic18f8722 i'm using to write to prog memory.

//load the holding registers
for (counter = 0; counter < uBOOTDIn.BiFWLen; counter++)
{
*((BiADR.pAdr)+counter) = uBOOTDIn.BiFWData[counter];
}
//first we fill the required holding registers
StartWrite();
while(EECON1_WR); //Wait till WR bit is clear

Where, BiFWLen is the length of the data to write to - usually 16
bytes.  The 8722 has a holding reg of 64 bytes - so no problem.  But
the pic18f452 has a holding reg of only 8 bytes so any ideas?  I've
tried :

if (uBOOTDIn.BiFWLen>8)
{
//load the holding registers
for (counter = 0; counter < 8; counter++)
{
 *((BiADR.pAdr)+counter) = uBOOTDIn.BiFWData[counter];
}
//first we fill the required holding registers
StartWrite();
while(EECON1_WR); //Wait till WR bit is clear

for (counter = 8; counter < uBOOTDIn.BiFWLen; counter++)
{
 *((BiADR.pAdr)+counter) = uBOOTDIn.BiFWData[counter];
}
//first we fill the required holding registers
StartWrite();
while(EECON1_WR); //Wait till WR bit is clear
}

But the problem is that when i check the program memory - the data is
not written to the correct address locations only on the
pic18f452 ????  ?

This doesn't make sense - the issue only occurs on the 452 even with
data <=8 bytes.  Is there any errata issues/hardware problems related
to the 452 / program memory?

Any help or sample code greatly appreciated.

I've seen http://ww1.microchip.com/downloads/en/DeviceDoc/80173c.pdf

Can someone explain section 6


Thanks