Tool/software: Code Composer Studio
I'm trying to use the TivaWare PWM Programming Example in my code on the TM4C123GH6PM. Below is the exact snippet I'm trying to use in a function which I call at the beginning of the program, with the only change being that I change "PWM_BASE" to "PWM0_BASE" so that I could access the Module 0 address:
void PWM0_init(void){
////////////////////////////////////////////////////////
//
// Enable the PWM0 peripheral
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);
//
// Wait for the PWM0 module to be ready.
//
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_PWM0))
{
}
//
// Configure the PWM generator for count down mode with immediate updates
// to the parameters.
//
PWMGenConfigure(PWM0_BASE, PWM_GEN_0,
PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC);
//
// Set the period. For a 50 KHz frequency, the period = 1/50,000, or 20
// microseconds. For a 20 MHz clock, this translates to 400 clock ticks.
// Use this value to set the period.
//
PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, 400);
//
// Set the pulse width of PWM0 for a 25% duty cycle.
//
PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, 100);
//
// Set the pulse width of PWM1 for a 75% duty cycle.
//
PWMPulseWidthSet(PWM0_BASE, PWM_OUT_1, 300);
//
// Start the timers in generator 0.
//
PWMGenEnable(PWM0_BASE, PWM_GEN_0);
//
// Enable the outputs.
//
PWMOutputState(PWM0_BASE, (PWM_OUT_0_BIT | PWM_OUT_1_BIT), true);
/////////////////////////////////////////////////////////////////////
}
The code compiles just fine. Based on my understanding from the datasheet, I should be seeing 50kHz square waves with 75% and 25% duty cycles coming out of PB6 and PB7 respectively but when I probe with an oscilloscope I get no voltage from either of those pins to ground. Could someone point out to me a perhaps obvious error I am making? I believe I had this working earlier with Module 1, PWM1 on PD1 but even when I change the code to reflect that I don't get any output.
Thanks!
Jim