Hi
I can enable PWM output on PF2/3, but not on PG0/1.
I guess that should be GPIO configuration problem, but I can't config it work.
Does anyone provide some suggestion for me?
//
// Set the PWM clock to the system clock.
//
SysCtlPWMClockSet(SYSCTL_PWMDIV_1);
//
// Enable the peripherals used by the Handle Light.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
HWREG(GPIO_PORTG_BASE + GPIO_O_AFSEL) &= ~0xFF;
HWREG(GPIO_PORTG_BASE + GPIO_O_AFSEL) |= 0x03;
HWREG(GPIO_PORTG_BASE + GPIO_O_DEN) |= 0x03;
HWREG(GPIO_PORTG_BASE + GPIO_O_PCTL) &= ~0xFF;
HWREG(GPIO_PORTG_BASE + GPIO_O_PCTL) |= 0x66;
//
// Set GPIO as PWM pins. They are used to output the PWM signals
//
GPIOPinConfigure(GPIO_PG0_M0PWM4);
GPIOPinConfigure(GPIO_PG1_M0PWM5);
GPIOPinTypePWM(GPIO_PORTG_BASE, GPIO_PIN_0);
GPIOPinTypePWM(GPIO_PORTG_BASE, GPIO_PIN_1);
GPIOPadConfigSet(GPIO_PORTG_BASE, GPIO_PIN_0, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD);
GPIOPadConfigSet(GPIO_PORTG_BASE, GPIO_PIN_1, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD);
//
// Set the PWM period to PWM_FREQUENCY
//
PWMGenConfigure(PWM0_BASE, PWM_GEN_2, PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC);
PWMGenPeriodSet(PWM0_BASE, PWM_GEN_2, 400);
//
// Start the PWM outputs with one clock long pulses.
//
PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, 200);
PWMPulseWidthSet(PWM0_BASE, PWM_OUT_1, 200);
PWMDeadBandEnable(PWM0_BASE, PWM_GEN_2, 5, 5);
//
// Disable the PWM0 output signals.
//
PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT, true);
PWMOutputState(PWM0_BASE, PWM_OUT_1_BIT, true);
//
// Enable the PWM generator.
//
PWMGenEnable(PWM0_BASE, PWM_GEN_2);
BTW, I work on TM4C129.
thanks,
Gavin