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 jitter by using the PIOSC

Part Number: TM4C123GH6PM


  Hi,

for a current project we are using the TM4C123GH6PM uC together with an FPGA. Our plan is to drive clock the FPGA from the uC to have run synchronized. To do that I've connected pin PB5 to the FPGA clock input set it up to work as PWM output M0PWM3. To clock the TM4C123GH6PM we're using the PIOSC and have configured it to run at 80MHz. The PWM module uses the SysCtl (80MHz) and outputs a PWM Signal of 80MHz (50/50).

Now the problem is that when I investigate the PWM signal on the scope everything looks good at the trigger point. But when I look at +2us I already see a jitter of about 7ns. This phenomenon increases over time. Now I've hooked up a Lauchpad (EK-TM4C123GK) to the scope and run the same code. It has the same issue. Ok so far. When I use the external 16 MHz crystal as clock source everything is stable.

I hope anyone can help me on this Topic.

I've pasted the relevent source code and two photos from the scope Investigation below:

// Set the system clock to run at 80Mhz

ROM_SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_INT);

ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);

//

// Configure the GPIO pin muxing to select PWM03 functions for these pins.

//

ROM_GPIOPinConfigure(GPIO_PB5_M0PWM3);

//

// Configure the PWM function for this pin.

//

ROM_GPIOPinTypePWM(FPGA_GPIO_PORT_BASE, FPGA_CLK_EN_PIN);

//

// Configure the PWM0 to count down without synchronization.

//

PWMGenConfigure(PWM0_BASE, PWM_GEN_1, PWM_GEN_MODE_DOWN);

//

// Set the PWM period to 16MHz. To calculate the appropriate parameter

// use the following equation: N = (1 / f) * SysClk. Where N is the

// function parameter, f is the desired frequency, and SysClk is the

// system clock frequency.

// In this case you get: (1 / 16MHz) * 80MHz = 5 cycles.

//

ROM_PWMGenPeriodSet(PWM0_BASE, PWM_GEN_1, 5);

//

// Set PWM0 to a duty cycle of 50%. You set the duty cycle as a function

// of the period. Since the period was set above, you can use the

// PWMGenPeriodGet() function.

//

ROM_PWMPulseWidthSet(PWM0_BASE, PWM_OUT_3,

ROM_PWMGenPeriodGet(PWM0_BASE, PWM_GEN_1) / 2);

//

// Enable the PWM0 Bit3 (PB5) output signal.

//

ROM_PWMOutputState(PWM0_BASE, PWM_OUT_3_BIT, true);

//

// Enable the PWM generator block.

//

ROM_PWMGenEnable(PWM0_BASE, PWM_GEN_1);

  • MathiasBuder said:

    When I use the external 16 MHz crystal as clock source everything is stable...    I hope anyone can help me on this Topic.  

    Has your investigation not revealed the advantage of external crystal/circuit over the, "internal oscillator?"

    The internal oscillator - from this vendor & others - most always is included for cost/size savings.    Where performance is critical - the external crystal circuit (still) reigns supreme...

  • As cb1-mobile pointed out, the PIOSC internal oscillator is not as stable as an external crystal. The internal oscillator frequency is affected by voltage and temperature. You will see the frequency  shift as the internal junction temperature increases. The "jitter" you measured of 7ns over 2us is 0.35%.

  • Beyond vendor "Bob's" mention of: Voltage & Temperature impacts upon MCU frequency - it is reasonable to include device "aging" as well as, "unit to unit" variation.

    The use of the external crystal circuit serves as the "Gold Standard" where "greatest" frequency accuracy & repeatability/precision are desired.

  • Hi,
    thank you very much for pointing that out to me. I'll go with an external crysten in the next PCB revision then.
  • Thank you - that's a wise decision when aimed at your "precision frequency" application.

    Do note the ongoing trend, "MCU as "Kitchen Sink" (i.e. Do everything) which may succeed for, "Quick/Short Kitchen Orders" - but surely is unsuited for gourmet fare.

    While size/cost reduction has a place - designers must carefully consider the ramifications (both known & unknown) introduced by such "savings."   And - glad to say - your curiosity leading to a systematic investigation - then clear reporting here - reaffirming the value proposition of the (long standard) EXTERNAL xtal circuit - proving most insightful...

    The internal oscillator (this vendor's & others') indeed has its place - offers advantages - yet each case is "special" and each demands careful consideration...