Hello,
I try to generate a PWM signal using of the PWMs modules. Basically, the steps involved in configuring the PWM are simple but I end up with a signal which stays permanently on HIGH. Please find below my initialization steps:
ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480), 120000000);
uint32_t period = ui32SysClock / 250; /*250 Hz*/
SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = 0x4C4F434B;
GPIOPinConfigure(GPIO_PF0_M0PWM0);
ROM_PWMClockSet(PWM0_BASE, PWM_SYSCLK_DIV_1);
GPIOPinTypePWM(PWM0_BASE, GPIO_PIN_0);
PWMGenConfigure(PWM0_BASE, PWM_GEN_0, PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC);
PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, period);
PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0_BIT, (period * 10) / 100); /*10%*/
PWMIntEnable(PWM0_BASE, PWM_INT_GEN_0);
PWMGenIntRegister(PWM0_BASE, PWM_GEN_0, pwmIsrCh0);
PWMGenIntTrigEnable(PWM0_BASE, PWM_GEN_0, PWM_INT_CNT_LOAD);
IntEnable(PWM0_BASE);
PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT, true);
PWMGenEnable(PWM0_BASE, PWM_GEN_0);
static void pwmIsrCh0(void)
{
uint32_t counter_value = (10 * period) / 100 ;
PWMGenIntClear(PWM0_BASE, PWM_GEN_0, PWM_INT_CNT_LOAD);
PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0_BIT, counter_value);
}
The ISR is successfully called.