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.
Greetings, im using a TM4C123GXL launchpad and I have a little problem in my PWM code. I'm configuring the PWM and i have it working, the problem is, when i place the PWMDeadbandEnable, the PWM value stay's on when it should be off.
void ConfigPWMPorts (void) {
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
SysCtlPWMClockSet(SYSCTL_PWMDIV_1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM1); //The Tiva Launchpad has two modules (0 and 1). Module 1 covers the LED pins
ulPeriod = SysCtlClockGet() / 8340; //PWM frequency 10kHz
GPIOPinConfigure(GPIO_PF2_M1PWM6);
GPIOPinConfigure(GPIO_PF3_M1PWM7);
GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_2 | GPIO_PIN_3);
PWMGenConfigure(PWM1_BASE, PWM_GEN_3, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_GEN_SYNC_LOCAL);
PWMGenPeriodSet(PWM1_BASE, PWM_GEN_3, ulPeriod);
PWMPulseWidthSet(PWM1_BASE, PWM_OUT_6,0);
PWMPulseWidthSet(PWM1_BASE, PWM_OUT_7,0);
PWMOutputInvert(PWM1_BASE, PWM_OUT_7_BIT, false);
PWMOutputInvert(PWM1_BASE, PWM_OUT_6_BIT, false);
PWMOutputState(PWM1_BASE, PWM_OUT_6_BIT | PWM_OUT_7_BIT, true);
PWMGenEnable(PWM1_BASE, PWM_GEN_3);
//PWMDeadBandEnable(PWM1_BASE, PWM_GEN_3, 100, 100);
}
if condition{
PWMOutputInvert(PWM1_BASE, PWM_OUT_7_BIT, false);
PWMPulseWidthSet(PWM1_BASE, PWM_OUT_6, ulPeriod); // PWM Period Set
PWMPulseWidthSet(PWM1_BASE, PWM_OUT_7, ulPeriod);
}
This condition is, if its true, keeps both PWM_OUT at same state and not changing, else, generate and place the deadband.
Well at least it should be, but what's happening is that if i uncoment the PWMDeadBandEnable, because i suppose it stays configured, the PWM goes to High on one port
Hello Victor
I am not sure but this is not a good idea to have PulseWidth as 0. Instead you can keep them as GPIO and only switch them to PWM mode when condition is true.
PWMPulseWidthSet(PWM1_BASE, PWM_OUT_6,0);
PWMPulseWidthSet(PWM1_BASE, PWM_OUT_7,0);
Regards
Amit
I changed that to ulPeriod, because if i dont use a value at these ports, i dont know in which state they are going to stay, so this way i garantee that PWM is at maximum or minimum and doesnt change the exit.
My problem is the DeadBand i want to implement
Hello Victor
OK. So by default you need the pair of PWM signal to be at maximum or minimum, i.e 1-0 or 0-1 but when the condition is true then the Dead Band Inserted in the changing pair of signals. Is that correct? If not, then can you please draw it out
Regards
Amit
Hello Victor
What was the issue and how did you resolve it. I may have to "Un-Verify" myself if there is not a definitive solution on the forum.
Regards
Amit