SLUAAP5 july 2023 UCD3138 , UCD3138064 , UCD3138064A , UCD3138128 , UCD3138128A , UCD3138A , UCD3138A64
zero_out_integrity_word function is used to clear the specified location of checksum. A lockup can occur when the zero_out_integrity_word function does not compile in 32-bit mode. This function is normally in an independent file named zero_out_integrity_word.c. The function name or file name can be slightly different from project to project, but generally looks like the following.
#define program_flash_integrity_word (*((volatile unsigned long *) 0x7ffc))
//last word in flash, when executing from Flash. used to store integrity code
void zero_out_integrity_word(void)
{
DecRegs.FLASHILOCK.all = 0x42DC157E;// Write key to Program Flash Interlock Register
DecRegs.MFBALR1.all = MFBALRX_BYTE0_BLOCK_SIZE_32K; //enable program flash write program_flash_integrity_word = 0;
DecRegs.MFBALR1.all = MFBALRX_BYTE0_BLOCK_SIZE_32K + MFBALRX_BYTE0_RONLY;
while(DecRegs.PFLASHCTRL.bit.BUSY != 0)
{
; //do nothing while it programs
}
return;
}
To check whether this function/file is compiled in 32-bit mode:
Note that this option is done with the configuration in CCS, so the zero_out_integrity_word function can possibly fail when the CCS version or compiler version is changed.
Another option is to use a preprocessor directive #pragma telling the compiler to compile the specified function in 32-bit mode. The following is an example.
#define program_flash_integrity_word (*((volatile unsigned long *) 0x7ffc))
//last word in flash, when executing from Flash. used to store integrity code
#pragma CODE_STATE(zero_out_integrity_word, 32) // 16 = thumb mode, 32 = ARM mode
void zero_out_integrity_word(void)
{
DecRegs.FLASHILOCK.all = 0x42DC157E;// Write key to Program Flash Interlock Register
DecRegs.MFBALR1.all = MFBALRX_BYTE0_BLOCK_SIZE_32K; //enable program flash write
program_flash_integrity_word = 0;
DecRegs.MFBALR1.all = MFBALRX_BYTE0_BLOCK_SIZE_32K + MFBALRX_BYTE0_RONLY;
while(DecRegs.PFLASHCTRL.bit.BUSY != 0)
{
; //do nothing while it programs
}
return;
}