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.

TM4C123GH6PM: PWM Problem

Part Number: TM4C123GH6PM


Hello All

My TM4C123GXL pwm output is not a constant wave. The output ripple is too high. Why could it be? What can i do?

The image may not belong to the following code, but the output is same.

#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_memmap.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/pwm.h"
#include "driverlib/sysctl.h"
int main(void)
{
uint16_t ui16Rise=2;
uint16_t ui16Fall=2;
SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
SysCtlPWMClockSet(SYSCTL_PWMDIV_1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
GPIOPinConfigure(GPIO_PB6_M0PWM0);
GPIOPinConfigure(GPIO_PB7_M0PWM1);
GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_6);
GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_7);
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_PWM0))
{
}
PWMGenConfigure(PWM0_BASE, PWM_GEN_0,PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC | PWM_GEN_MODE_DBG_STOP);
PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, 200);
PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, 130);
PWMDeadBandEnable(PWM0_BASE, PWM_GEN_0, ui16Rise, ui16Fall);
PWMGenEnable(PWM0_BASE, PWM_GEN_0);
PWMOutputState(PWM0_BASE, (PWM_OUT_0_BIT | PWM_OUT_1_BIT), true);
    while(1)
    {
}
}


Thanks.
  • Where do the PWM signals go to on your PCB board? How long is the signal trace? It is also possible that the ringing may be measurement error because the scope isn't seeing exactly the same ground the signal is. So make sure the probe from scope is ground to the signal ground. Normally, a simple series resistor for termination can help alleviate the problem. First check other things I mentioned (trace length, ground).
  • Hi Charles,

    As poster notes use of  "PB6 & PB7" - (should his board be an  "LPad") and those pins are (delightfully) directly connected to PD0 & PD1 (each) - might that influence poster's waveform?     (especially so if PD0/PD1 are employed as outputs!)

    I'd add to your advice that the "Shortest possible Scope Ground Lead" should be employed."     To really view the signal - NO ground lead should be used - instead - a "wire loop" - contacting the probe's ground body - and tied to ground - provides the best insight into such signals...