I am also struggling with resetting the fault.
If I single step through the reset procedure, it works fine. The FLTSTAT gets reset and the PWM starts up again.
If I run the code without breaks, the PWM stays off. If I then pause and look at the SFR's the FLTSTAT has not reset.
I have tried the delay between the FLTMOD=0b11 and FLTMOD=0b00, still no joy!
I am setting a flag in the PWM interupt routine and disabling the FLTIEN.
void __attribute__ ( ( interrupt, no_auto_psv ) ) _PWM1Interrupt ( )
LATDbits.LATD1=1; // for scope checking
if (PWMCON1bits.FLTSTAT == 1)
IFS5bits.PWM1IF = false;
In the main code I check for Fault flag that I set in Interrupt, then check FLT1/ RA2. (Is there a way to check FLT1 other then reading the pin RA2?)
I then proceed to reset the FLTSTAT by setting and resetting FLTMOD<1:0> with a delay inbetween.
Finaly, enabling interupt again and resetting my FAULT flag.
NOW pwm is suppose to be pulsing.
But it happens only when I single step through the code??
__builtin_write_PWMSFR(&FCLCON1, 0x80B, &PWMKEY);
__builtin_write_PWMSFR(&FCLCON2, 0x80B, &PWMKEY);
__builtin_write_PWMSFR(&FCLCON1, 0x808, &PWMKEY);
__builtin_write_PWMSFR(&FCLCON2, 0x808, &PWMKEY);