Hello
I am trying to get the M0PWM3 output on my TM4C129ENCPDT device to work with no luck. Just using it as continous freq output to drive a buzzer. I have been through lots of examples and cannot see anything I am missing, but something must be wrong.
Using pin 45 - PF3 - M0PWM3
Here's what I am doing, if you can advise what is wrong would be great.
Hardware pin initialisation
// Output Functions PWM
ROM_GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_3);
// Buzzer
ROM_GPIOPinConfigure(GPIO_PF3_M0PWM3);
Buzzer enable Fn
void EnableBuzzer(uint32_tfreq)
{
uint32_t ulPeriod;
ulPeriod =
SysCtlClockGet() / freq;
SysCtlPWMClockSet(SYSCTL_PWMDIV_1); // PWM Clock is system clock
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);
// Enable PWM module 0
//Configure PWM0 G1 as UP/DOWN counter with no sync of updates
ROM_PWMGenConfigure(PWM0_BASE, PWM_GEN_1, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC);
ROM_PWMGenPeriodSet(PWM0_BASE, PWM_GEN_1, ulPeriod);
// set the frequency
ROM_PWMPulseWidthSet(PWM0_BASE, PWM_OUT_3, ROM_PWMGenPeriodGet(PWM0_BASE, PWM_OUT_3) / 2);
// 50% duty cycle
ROM_PWMOutputState(PWM0_BASE, PWM_OUT_3_BIT, false);
ROM_PWMGenEnable(PWM0_BASE, PWM_GEN_1);
}
Buzzer ON Function
PWMOutputState(PWM0_BASE, PWM_OUT_3_BIT, true);