PIC18f452 Program Memory Problem

Aug 18, 2008 1 Replies

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


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

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required