hi ,
1. the code below is from AN3275,the author want to erase Paged Memory of the block 0(except the page 0x3F):
------------------------------------------------------------------------------------------------------------------------------
PPAGE=0x3E;
li16PageAddressPointer=0xBFFF;
li16BootAddressPointer = 0xFFFF;
while(PPAGE>li8Page)
{
if(*(uint8 *)(li16BootAddressPointer) != *(uint8 *)(li16PageAddressPointer))
{
/*
* Erase Paged Memory
*/
gi32FlashAddressH = PPAGE;
for(gi32FlashAddressL=0xBF00;gi32FlashAddressL>=0x8000;gi32FlashAddressL-=0x200){
gi16FlashDataCounter = 1;
if (vfnFlash_Cmd(FErase))
{
vfnSCITxMsg(&gi8aFlashErrorMsg[0]);
return;
}
}
PPAGE--;
li16PageAddressPointer = 0xC000;
li16BootAddressPointer = 0x0000;
}
li16BootAddressPointer--;
li16PageAddressPointer--;
if(li16BootAddressPointer<0xF000){PPAGE = 0x36;}
}
------------------------------------------------------------------------------------------
but ,in my opinion ,the code below is enough for erase those flash:
----------------------------------------------------------------------------------------------------
PPAGE=0x3E;
while(PPAGE>li8Page)
{
gi32FlashAddressH = PPAGE;
for(gi32FlashAddressL=0xBF00;gi32FlashAddressL>=0x8000;gi32FlashAddressL-=0x200){
gi16FlashDataCounter = 1;
if (vfnFlash_Cmd(FErase))
{
vfnSCITxMsg(&gi8aFlashErrorMsg[0]);
return;
}
}
PPAGE--;
}
---------------------------------------------------------------------------------------------------------------
could you tell me why the author add the other statement, thanks!
2. it seems that the author want to write the user‘s reset vector to 0xEFFE,but it doesn’t work,could you help me to solve it ,thank you!
-----------------------------------------------------------------------------------------------------------------
if(gi32FlashAddressL >= (1 - gi16FlashDataCounter)) //Reset Vector
{
if(!S19UpdatingLoader)
{
gi16FlashDataCounter--;
gi16FlashDataCounter--;
ResetVector = *(uint16 *)(&gi8aS19Buffer[gi16FlashDataCounter+4]);
}
}
gi16FlashDataCounter >>= 1;
/* A single S19 record line shouldn't be longer than 0x20 bytes*/
li8Error = vfnFlash_Cmd(Program);
gi8S19Status &= ~((1<<S19RxComplete)|(1<<S19RxOk));
if (!--li8LineCounter)
{
SCI0DRL = '.';
li8LineCounter = 0x20;
}
}
}
if (S19UpdatingLoader)
{
vfnSCITxMsg(&gi8UpdateLoaderMsg[0]);
vfnpUpdateFn();
}
else
{
gi16FlashDataCounter=1;
gi32FlashAddress = 0xEFFE;
gi8FlashBlock = 0;
gi16pFlashDataPtr = (uint16)&ResetVector;
(void)vfnFlash_Cmd(Program);
}
I too do not understand why the above statement was added and why the reset vector has to be programmed seperately. Can you share if you have any idea ?