Hello,
I found that there are two different ways to copy the codes of "zero_out_integrity_word" to RAM from Pflash and then execute it to clear the Pflash checksum, shown as below. Which way is better?
One way in LLC demo code:
{
register Uint32 * program_index = (Uint32 *) 0x19000; //store destination address for program
register Uint32 * source_index = (Uint32 *)zero_out_integrity_word; //Set source address of PFLASH;
register Uint32 counter;
for(counter=0; counter < 32; counter++) //Copy program from PFLASH to RAM
{
*(program_index++)=*(source_index++);
}
}
{
register FUNC_PTR func_ptr;
func_ptr=(FUNC_PTR)0x19000; //Set function to 0x19000
func_ptr();
DecRegs.MFBALR1.bit.RONLY = 1; //restore it to read only
DecRegs.MFBALR17.bit.RONLY = 1; //restore it to read only
SysRegs.SYSECR.bit.RESET= 2; //reset device
}
return;
The other way in PFC demo code:
register Uint32 * program_index = (Uint32 *) program_area; //store destination address for program
register Uint32 * source_index = (Uint32 *) zero_out_integrity_word_start; //Used for source address of PFLASH;
register Uint32 counter;
for(counter=0; counter < 32; counter++) //Copy program from PFLASH to RAM
{
*(program_index++)=*(source_index++);
}
zero_out_integrity_word();
return;