Problem: When using S32K144 to generate MAC value calculation, while waiting for the execution of the CSEc command CMD_GENERATE_MAC, the P-Flash is accessed asynchronously, and the result is reset, as follows:
long int index;
unsigned int *add = (unsigned int *)0x0;
void CSEC_WriteCmdAndWait(csec_cmd_t funcId,
csec_func_format_t funcFormat,
csec_call_sequence_t callSeq,
csec_key_id_t keyId)
{
char i;
CSE_PRAM->RAMn[0].DATA_32 =
CSE_PRAM_RAMn_DATA_32_BYTE_0(funcId) |
CSE_PRAM_RAMn_DATA_32_BYTE_1(funcFormat) |
CSE_PRAM_RAMn_DATA_32_BYTE_2(callSeq) |
CSE_PRAM_RAMn_DATA_32_BYTE_3(keyId);
while ((FTFC->FSTAT & FTFC_FSTAT_CCIF_MASK) == 0U)
{
/* Wait until the CCIF flag is set */
for (index = 0; index < 10 *1024; index++)
{
i = add[index];
}
}
}
It is ok to wait for the command execution to complete in while, but reset occurs when accessing data on p-flash