Hi Sangamesh Vandal,
This the code from the KSDK, you can find the FAULT clear code:
void FTM_ClearStatusFlags(FTM_Type *base, uint32_t mask)
{
/* Clear the timer overflow flag by writing a 0 to the bit while it is set */
if (mask & kFTM_TimeOverflowFlag)
{
base->SC &= ~FTM_SC_TOF_MASK;
}
/* Clear fault flag by writing a 0 to the bit while it is set */
if (mask & kFTM_FaultFlag)
{
base->FMS &= ~FTM_FMS_FAULTF_MASK;
}
/* Clear channel trigger flag */
if (mask & kFTM_ChnlTriggerFlag)
{
base->EXTTRIG &= ~FTM_EXTTRIG_TRIGF_MASK;
}
#if defined(FSL_FEATURE_FTM_HAS_RELOAD_INTERRUPT) && (FSL_FEATURE_FTM_HAS_RELOAD_INTERRUPT)
/* Check reload flag by writing a 0 to the bit while it is set */
if (mask & kFTM_ReloadFlag)
{
base->SC &= ~FTM_SC_RF_MASK;
}
#endif
/* Clear the channel status flags by writing a 0 to the bit */
base->STATUS &= ~(mask & 0xFFU);
}
Please take care, when you clear the fault, you should make sure there has no other fault condition is detected, otherwise, the FAULTF remains set.
You can debug your code, after the fault happens, then remove the fault condition, and clear the FAULTF flag, and check the flag again, whether it is successfully cleared.
If you still have question, please give me some picture about your debug register.
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------