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.

TM4C1294KCPDT: how to generate a 12MHz frequency from a CCP pin?

Part Number: TM4C1294KCPDT
Other Parts Discussed in Thread: ALLIGATOR

Hi,

I follow the app note for emulating the I2S by using 2 SPI interface (http://www.ti.com/lit/pdf/spma042), and I need to generate the MCLK by using the CCP pin from the MCU.

When I config a CCP pin to generate this 12MHz frequency, the amplitude output from the pin is very low (less than 1V), and the waveform looks like a sine wave, rather than a square wave. My system is running on 3.3V supply voltage.

Is there any thing I make it wrong for this 12MHz frequency? What is the correct setting for generate this 12MHz frequency from the CCP pin?

Thanks!

Regards,

Franky Chan

  • Good morning Franky,

    I had just posted a similar piece of code for this thread where we discussed frequency generation with timers and PWM.

    e2e.ti.com/.../593475

    Hence, it took me less than a minute to recompile it with different parameters. The code below configures a TCCP for 12MHz wave:

        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
        while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOD)));
        SysCtlPeripheralDisable(SYSCTL_PERIPH_TIMER1);
        SysCtlPeripheralReset(SYSCTL_PERIPH_TIMER1);
        SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
        while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_TIMER1)));
        GPIOPinTypeTimer(GPIO_PORTD_BASE, GPIO_PIN_3);
        GPIOPinConfigure(GPIO_PD3_T1CCP1);
        TimerConfigure(TIMER1_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_B_PWM);
        TimerLoadSet(TIMER1_BASE, TIMER_B, 9);
        TimerMatchSet(TIMER1_BASE, TIMER_B, 4);
        TimerControlLevel(TIMER1_BASE, TIMER_B, false); // Just an example to make the timer PWM active high
        TimerEnable(TIMER1_BASE, TIMER_B);
    

    This is what the signal looks like on a launchpad here:

    The amplitude looks fine, although I do have some rounding on the transitions. Still, the TTL region is safely high/low. What are you getting?

    Regards

    Bruno

  • Bruno Saraiva said:
    do have some rounding on the transitions

    Hate to view "real" over/under-shoot then.

    With a "load of 9" - and a "match of 4" - is it (only) the average duty cycle which "rounds" to 50%?

    It would be useful to keep that set-up - and produce output waveforms of 10, 5, 1 MHz and 500, 250 KHz.

    I'd bet that your scope probe's ground lead was on - and that much of the waveform distortion - could be reduced if a "leadless" (i.e. ground connection via a short, "wire-loop") was employed, instead.   (that wire loop ties to ground - which is "directly" in line w/the MCU Timer pin - so that the ground lead is OFF - and the connection is as short/direct as possible!)

    You (may) have noted that poster appears to have achieved 12MHz output (by copying the App Note) and it is possible (perhaps likely) that this MCU has not much output drive @ such frequency.     (which proves "why" - "one & only one MCU/Vendor" proves "unwise" as it SO LIMITS Choice - and mission satisfaction.     It is noted that (real) I2S MCUs lurk nearby - far outperform - & escape such "pound into (almost) submission" attempts.)

  • cb1_mobile said:
    With a "load of 9" - and a "match of 4" - is it (only) the average duty cycle which "rounds" to 50%?

    Not really! This setting gives always 50%. That's something related to how the counting registers work... This setup cycles the timer from 0 to 9 (10 cycles), and flips the duty after counter matches 4 (in other words, half way through)...

    I (too) expected 10 and 5 to be the correct parameters, but those actually product ~11MHz! These minor details don't matter too much when using low clocks, but the correct parameter for the frequency appears to be:
    SystemClock/Frequency-1, instead of the easy-to-read SystemClock/Frequency.

    YES, good feeling to "design once and display often" (apparently edited out later?)

    cb1_mobile said:
    I'd bet that your scope probe's ground lead was on - and that much of the waveform distortion - could be reduced if a "leadless" (i.e. ground connection via a short, "wire-loop") was employed, instead.   (that wire loop ties to ground - which is "directly" in line w/the MCU Timer pin - so that the ground lead is OFF - and the connection is as short/direct as possible!)

    I honestly don't know what this means... This is probably my "mechanical engineering degree" crying out again, but I am not familiar with this leadless concept.

    As for the driving capacity of the GPIO, two things that could still be tried:

    - Confirm that the chosen pad accepts higher current and configure it as such (8mA? 12mA?) AFTER configuring the pin using the macro call?
    - Try with some sort of high impedance OpAmp?

    Worth mentioning that I tested the same software all the way to 60MHz signal output (load 1, match 0), in which case it REALLY looked like a sinusoidal wave!!!

    Greetings

    Bruno

  • If time allows I'll "find & cut/paste" such a "Ground Lead-less" scope technique. ALL scope vendors recommend this technique - the ground lead is provided for convenience - yet serves to "pick-up unwanted signals & distorts those of great interest - both emphasized when the device operates at (near) limits.

    here's a link which very well illustrates.    (Fig 4 shows the "normal" scope ground connection, Fig 7 shows the "wire-loop" method - and much improved signal measure.)

       For some unexplained reason I cannot "snip" the image...

  • Arrives now - (reasonable quality photo) of the technique described (above post.)     The "added" wire loop contacts the probe's metal ground ring and pcb ground - yielding a "far truer" scope picture!

  • Just noticed this, cb1 - thanks for the posting.
    The defected ugly waves earlier on this post are not important for this particular discussion, but the short ground is CERTAINLY to be flashed into my knowledge for future serious signal probing.
    It definitely looks like what I was seeing with the scope at 12MHz and then worse at 60MHz.
    My GND probe was just something actually longer than the standard scope lead: it was probably that alligator clip connected to another 10" piece of wire then into a GND pin on the PCB!
    Regards
  • You are welcome, Bruno - and I believe that your scope views/measurements (especially those at higher frequencies) - will much benefit from this technique.

    The added inductance - which the "standard" scope ground lead imposes - is able to store & then release transient voltages - which degrades & distorts measurements.

    Note also that "Differential Scope Probes" may also come into play.     (consider the case when measuring VGS - at the "High Side" of a Half-Bridge FET configuration.)      Employing the scope's (usual) ground - and connecting it to the Half-Bridge's "Switching Output" - may provide (unwanted) excitement.       (Don't do this!)  

    Enter the Differential Scope Probe  - possessing the ability to measure between 2 circuit points (without respect to ground - but instead - with respect to "each other.")       This is yet another technique which proves highly useful.   (and sometimes required!)

  • cb1_mobile said:
    "Differential Scope Probes" may also come into play.  

    I know...

    I've been meaning to buy a good set of diff probes forever, but never remember it! Next time I visit the dist site, I guess (living in Europe you learn to buy batches of equipment/components from Poland, so to save freight you wait for the next real need!)

    One other (somehow related) goal here is to fully isolate the GND that powers my PC from the GND that powers the scope, because several of our boards have some sort of protecting inductors on the power entry, which kind of offset the zero reference a bit - and that is not good for debugging situations in which either USB or a regular RS232 are connecting the boards to the PC. The AC isolated transformers are already here, just a matter of set it all up.

    Regards

    Bruno