Hi Peter,
I don't step in debugger according to your answer,and I called the function FCCU_clear_faults() at the start of main function,but it return 1 of ret_val that shows it can't cleared all FCCU errors. So it still can't enter config state. I don't know the reason or there are other errors in my codes?The following codes are three functions of FCCU.
void FCCU_Init(void)
{
/*switch FCCU into CONFIG mode*/
/*1. unlock CONFIG state*/
FCCU.TRANS_LOCK.R = 0xBC;
/*2. Key for OP1 */
FCCU.CTRLK.R = 0x913756AF;
/*3. OP1: Set FCCU to CONFIG mode*/
FCCU.CTRL.R = 1;
/*4. wait untill switching to CONFIG mode*/
while(FCCU.CTRL.B.OPS != 3);
/* enable reaction for fault 14(SWT) */
FCCU.NCFS_CFG.B.NCFSC14 = 0x1; //short reset
/*switch FCCU back to NORMAL mode*/
/*1. Key for OP2*/
FCCU.CTRLK.R = 0x825A132B;
/*2. OP2: Set FCCU to NORMAL mode*/
FCCU.CTRL.R = 2;
/*3. wait untill switching to NORMAL mode*/
while(FCCU.CTRL.B.OPS != 3);
}
void Read_FCCU_NCF_S(uint32_t *pu32FccuNcfStatus)
{
/*1. Read the NCF status register (see the FCCU_NCF_S register)*/
FCCU.CTRL.R = 0xA;
/*2. wait untill switching to CONFIG mode*/
while(FCCU.CTRL.B.OPS != 3);
/*3. read the Status*/
*pu32FccuNcfStatus++ = FCCU.NCF_S[0].R;
*pu32FccuNcfStatus++ = FCCU.NCF_S[1].R;
*pu32FccuNcfStatus++ = FCCU.NCF_S[2].R;
}
/**********************************************************************************************
* This function clear all FCCU_NCF_S0/1/2 bits by writing key to FCCU.NCFK.R register.
* And will store the updated FCCU_NCF_S0/1/2 bits into the parameter pu32Status
* Return 0 if all FCCU errors were cleared; otherwise return 1;
**********************************************************************************************/
uint32_t FCCU_clear_faults(void)
{
uint32_t u32TmpFccuNcfStatus[3];
uint32_t u32Tmp = 0;
uint32_t ret_val = 0;
for(u32Tmp = 0; u32Tmp < 3; u32Tmp++)
{
/*1. Key for NCFS clearing*/
FCCU.NCFK.R = 0xAB3498FE;
/*2. Clear all the NCF status(OP12)*/
FCCU.NCF_S[u32Tmp].R = 0xFFFFFFFF;
/*3. wait untill switching to NORMAL mode*/
while(FCCU.CTRL.B.OPS != 3);
/*4. read NCF_S with vfnRead_FCCU_NCF_S and check if all the flag is cleared*/
Read_FCCU_NCF_S(u32TmpFccuNcfStatus);
if(u32TmpFccuNcfStatus[u32Tmp]!=0)
ret_val = 1;
}
return ret_val;
}
Best Regards,