This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software:
I'm trying to get two identical pulse streams out of PWM0, GEN0 and GEN2. I get the pulses out of GEN0 at PF0 but nothing out of GEN2 at PF2.
GPIOPinTypePWM(GPIO_PORTF_BASE, 0x01);
GPIOPinConfigure(GPIO_PF0_M0PWM0);
GPIOPinTypePWM(GPIO_PORTF_BASE, 0x04);
GPIOPinConfigure(GPIO_PF2_M0PWM2);
PWMClockSet(PWM0_BASE, PWM_SYSCLK_DIV_16); // 1250KHz Clock.
PWMGenConfigure(PWM0_BASE, PWM_GEN_0, PWM_GEN_MODE_DOWN | //
PWM_GEN_MODE_NO_SYNC ); //
PWMDeadBandDisable(PWM0_BASE, PWM_GEN_0); //
PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, 1250); // 1KHz output.
PWMPulseWidthSet(PWM0_BASE, PWM_GEN_0, 625); // 50% duty cycle.
PWMOutputUpdateMode(PWM0_BASE, PWM_OUT_0_BIT, PWM_OUTPUT_MODE_SYNC_LOCAL); // Output change on 0 count.
PWMGenEnable(PWM0_BASE, PWM_GEN_0); //
PWMGenConfigure(PWM0_BASE, PWM_GEN_2, PWM_GEN_MODE_DOWN | //
PWM_GEN_MODE_NO_SYNC ); //
PWMDeadBandDisable(PWM0_BASE, PWM_GEN_2); //
PWMGenPeriodSet(PWM0_BASE, PWM_GEN_2, 1250); // 1KHz output.
PWMPulseWidthSet(PWM0_BASE, PWM_GEN_2, 625); // 50% duty cycle.
PWMOutputUpdateMode(PWM0_BASE, PWM_OUT_2_BIT, PWM_OUTPUT_MODE_SYNC_LOCAL); // Output change on 0 count.
PWMGenEnable(PWM0_BASE, PWM_GEN_2); //
PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT | PWM_OUT_2_BIT, true); // Turn on PWM output.
Thanks, Doug
Hi Doug,
If you want to use PF0 and PF2 for PWM pins then you need to configure as follows.
GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_2);
What you had currently will first enable PF0 and later enable PF2 but disable PF0 for PWM control.
GPIOPinTypePWM(GPIO_PORTF_BASE, 0x01); // Enable PF0 only
GPIOPinConfigure(GPIO_PF0_M0PWM0);
GPIOPinTypePWM(GPIO_PORTF_BASE, 0x04); // Enable PF2 only unless you write 0x5 in which both PF0 and PF2 are controlled by PWM module.
GPIOPinConfigure(GPIO_PF2_M0PWM2);
Hi Charles,
No, didn't fix it. In fact even how I was initializing the ports M0PWM0 on PF0 still worked.
Thanks, Doug
Hi Doug,
If you comment out all code associated with PF0 using GEN0, does it make a difference? let's focus on PF2 only.
Still no output pulse stream.
GPIOPinTypePWM(GPIO_PORTF_BASE, 0x04);
GPIOPinConfigure(GPIO_PF2_M0PWM2);
PWMClockSet(PWM0_BASE, PWM_SYSCLK_DIV_16);
PWMGenConfigure(PWM0_BASE, PWM_GEN_2, PWM_GEN_MODE_DOWN |
PWM_GEN_MODE_NO_SYNC );
PWMDeadBandDisable(PWM0_BASE, PWM_GEN_2);
PWMGenPeriodSet(PWM0_BASE, PWM_GEN_2, 1250);
PWMPulseWidthSet(PWM0_BASE, PWM_GEN_2, 625);
PWMOutputUpdateMode(PWM0_BASE, PWM_OUT_2_BIT, PWM_OUTPUT_MODE_SYNC_LOCAL);
PWMGenEnable(PWM0_BASE, PWM_GEN_2);
Thanks, Doug
Hi Doug,
PF2 pin which outputs PWM2 is controlled by PWM_GEN_1, not PWM_GEN_2 as I see in your code.