Other Parts Discussed in Thread: SW-DRL
Hello again, I've been burning countless hours trying to figure this out. I can't understand what is it that I am doing wrong.
I want to configure the PWM fault to LATCH when a fault is present, then clear manually. Fault functionality works well when UNLATCHED, but when LATCHED I cannot clear the fault. Here goes the configuration code:
// set pwm system clock
SysCtlPWMClockSet(SYSCTL_PWMDIV_1);
// enable peripherals
SysCtlPeripheralEnable(SYSCTL_PERIPH2_GPIOA);
SysCtlPeripheralEnable(SYSCTL_PERIPH2_GPIOF);
SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM1);
// unlock GPIO PF0 - see errata / pin defaults to NMI and is locked
GPIO_PORTF_LOCK_R = GPIO_LOCK_KEY;
GPIO_PORTF_CR_R = GPIO_PIN_0;
// enable alternate function
GPIOPinConfigure(GPIO_PA6_M1PWM2);
GPIOPinConfigure(GPIO_PA7_M1PWM3);
GPIOPinConfigure(GPIO_PF0_M1PWM4);
GPIOPinConfigure(GPIO_PF1_M1PWM5);
GPIOPinConfigure(GPIO_PF4_M1FAULT0);
// configure pads
GPIOPinTypePWM(GPIO_PORTA_BASE, GPIO_PIN_6 | GPIO_PIN_7);
GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_1);
GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_4);
// configure PWM generators
PWMGenConfigure(PWM1_BASE, PWM_GEN_1, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC | PWM_GEN_MODE_FAULT_LATCHED);
PWMGenConfigure(PWM1_BASE, PWM_GEN_2, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC | PWM_GEN_MODE_FAULT_LATCHED);
// set PWM generators periods
PWMGenPeriodSet(PWM1_BASE, PWM_GEN_1, 1666);
PWMGenPeriodSet(PWM1_BASE, PWM_GEN_2, 1666);
// set pulse width
PWMPulseWidthSet(PWM1_BASE, PWM_OUT_2, 1666 / 2);
PWMPulseWidthSet(PWM1_BASE, PWM_OUT_4, 1666 / 2);
// enable deadband
PWMDeadBandEnable(PWM1_BASE, PWM_GEN_1, 10, 10);
PWMDeadBandEnable(PWM1_BASE, PWM_GEN_2, 10, 10);
// enable PWM bits
PWMOutputState(PWM1_BASE, PWM_OUT_2_BIT | PWM_OUT_3_BIT | PWM_OUT_4_BIT | PWM_OUT_5_BIT, true);
// configure fault input
PWMGenFaultConfigure(PWM1_BASE, PWM_GEN_1, 10, PWM_FAULT0_SENSE_LOW);
PWMGenFaultConfigure(PWM1_BASE, PWM_GEN_2, 10, PWM_FAULT0_SENSE_LOW);
PWMGenFaultTriggerSet(PWM1_BASE, PWM_GEN_1, PWM_FAULT_GROUP_0, PWM_FAULT_FAULT0);
PWMGenFaultTriggerSet(PWM1_BASE, PWM_GEN_2, PWM_FAULT_GROUP_0, PWM_FAULT_FAULT0);
PWMOutputFault(PWM1_BASE, PWM_OUT_2_BIT | PWM_OUT_3_BIT | PWM_OUT_4_BIT | PWM_OUT_5_BIT, true);
PWMOutputFaultLevel(PWM1_BASE, PWM_OUT_2_BIT | PWM_OUT_3_BIT | PWM_OUT_4_BIT | PWM_OUT_5_BIT, false);
// enable the generators
PWMGenEnable(PWM1_BASE, PWM_GEN_1);
PWMGenEnable(PWM1_BASE, PWM_GEN_2);
// sync the time base (execute after enabling generators)
PWMSyncTimeBase(PWM1_BASE, PWM_GEN_1_BIT | PWM_GEN_2_BIT);
To clear the fault, I call a function that executes this:
PWMGenFaultClear(PWM1_BASE, PWM_GEN_1, PWM_FAULT_GROUP_0, PWM_FAULT_FAULT0);
PWMGenFaultClear(PWM1_BASE, PWM_GEN_2, PWM_FAULT_GROUP_0, PWM_FAULT_FAULT0);
The fault is cleared but the PWM output is not restored (pins go low). Can anyone tell me what is is that I am missing? LM4F232 on EKK-LM4F232, Keil.
Thanks.