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: what is tm4c123 microcontroller maximum speed at GPIO pins

Part Number: TM4C123GH6PM

What is the maximum frequency of square wave i can get from at a GPIO pin of this microcontroller. I wrote a code where i used the inbuilt PLL as clock source working at 80 Mhz an whith the help of iinterrupt. but i'm able to get 550Khz square wave at one of the GPIO pin. what i need is about 2Mbps speed at output. What should i do?

  • If all you want is a square wave, I suggest you use a general purpose timer, or PWM timer. It is much more efficient to let the hardware generate the square wave.
  • you aren't getting that fast because you are doing it wrong - with an interrupt.

    simply flipping a pin takes at least two instructions. or 40Mhz on a 80Mhz mcu. that's max you can get. anything less than that is possible.
  • Danny F said:

    simply flipping a pin takes at least two instructions. or 40Mhz on a 80Mhz mcu. that's max you can get. anything less than that is possible.

    There are limitations beyond instruction clock. (Loop overhead, instructions per cycle, access times etc...) Bruno measure the fastest he could achieve at 20 MHz

    https://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/p/506050/1840865#1840865

    PWM should be capable of faster. Whether that's useful is another question. Certainly if all you are doing is making a square wave it would be a waste of resources to use the processor over a PWM.

    Bitbanging an output at ~2MHz may be doable (although I'd question the necessity).  Doing it at exactly 2MHz may be a fools errand.

    Robert

  • "Bruno measure the fastest he could achieve at 20 MHz"

    obviously he is doing it wrong:

    0x000006D0 F8C02080  STR      r2,[r0,#0x80]
        61:                 LED_PORT->RESERVED0[LED] = LED; 
    0x000006D4 F8C01080  STR      r1,[r0,#0x80]
        62:                 LED_PORT->RESERVED0[LED] =~LED; 
    

    from good old Keil 3.24. STR is a single-cycle instruction. So if you fill the loop with that, you will be running at 1/2 of main clock.

  • Might it be (reasonably) expected that poster's application will extend (beyond) a single, endless loop? If so - the brutality & limitation of "such method" will quickly become apparent.     In addition - producing a proper 40MHz output waveform - from this class MCU - proves extremely unlikely!    

    Assuming (some) real MCU work is to be achieved - use of one of the MCU's (many) Timers - configured into PWM mode - should achieve a "stable" (hardware based) 2MHz clock output - WHILE enabling multiple other (normal) MCU operations & processes...     Which (effectively) meets "Real-World" usage requirements...

  • Actually, i want to generate a 12 bit counter which runs from all 0's to all 1's and again back all 0's(endless loop) at precisely 1.024Mhz  rate..For this application also will PWM work ? if yes how do i configure PWM for 12bits counter at 1.024Mhz frequency?

  • "For this application also will PWM work ?"

    actually, have you thought about using the eusci module? it would work wonderfully here.
  • siddharth goyal said:
    Actually, i want to generate a 12 bit counter which runs from all 0's to all 1's and again back all 0's(endless loop) at precisely 1.024Mhz  rate.

    It is ALWAYS "distressing" - even "Crazy Making" - to receive such "Actually" ...  late in the Requesting Sequence.      Should this detail not have been presented - initially?

    Your "newly introduced" (Actuality) bears little resemblance to your thread's Subject/Title - and the new detail was NOWHERE presented (nor hinted) earlier.    Not good!

  • Danny,

    I will immediately PayPal transfer you US$ 100 if you can generate 40MHz "frequency of square wave" [quoting OP] using a TM4C123 configured at 80MHz, applying your "good old Keil 3.24" elocubration.

    Sentences like "OBVIOUSLY HE IS DOING IT WRONG" should rather be backed up by real life tests and proof of concept.

    Further, there are two peripherals on this MCU designed specifically for hardware controlled digital signal output, namely General Purpose Timers and PWM Module, as Mastermind-ranked Bob Crosby wisely suggested... But rather, you land here by parachute on a gusty day, and suggest "eusci module" to generate a square signal output. Genious! Why don't you also help the cause and provide a working example of that, so that we all can learn?

    Regards

    Bruno
  • Bruno Saraiva said:
    you land here by parachute on a gusty day

    Oh Bruno - its NOT (that) gusty!       And (lowercase poster) Danny DID - "Stick his landing!"

    Earlier - one here - noted that this class MCU's output structure is "highly unlikely" to generate (anywhere near) proper - 40MHz output...

    (overheard: ... ...  "Is that a flack-jacket you're wearing - or are you (happy) to see me?")

  • As cb1 so well put it here, you'd rather create a new thread and ask about your real goal.
    I believe the best way to achieve it is using DMA and a Timer. I just fear that the closest to 1.024 MHz you can achieve will be 1.02041...

    But it would not be elegant to discuss the solution here, because if someone in the future searches for something like that, he will never look at a thread named "tm4c123 microcontroller maximum speed at GPIO pins".
    So if you kindle create a new post (the title question on this one is answered already), we will help you there.
    Bruno
  • siddharth goyal said:
    Actually, i want to generate a 12 bit counter which runs from all 0's to all 1's and again back all 0's(endless loop) at precisely 1.024Mhz  rate..

    You want to have a 12 bit parallel output? Or are you just feeding a clock to an external counter? In either case why? What's your ultimate goal?

    Precisely at 1.024MHz? How about accuracy and repeatability? Bitbanging this is unlikely to produce the latter especially if you do anything else on the micro.

    siddharth goyal said:
    For this application also will PWM work ?

    Can you produce a MHz signal with PWM? Yes. However, especially given the lack of detail so far whether you can easily meet you specifications is unknowable.

    Robert

  • Danny F said:

    obviously he is doing it wrong:

    0x000006D0 F8C02080  STR      r2,[r0,#0x80]
        61:                 LED_PORT->RESERVED0[LED] = LED; 
    0x000006D4 F8C01080  STR      r1,[r0,#0x80]
        62:                 LED_PORT->RESERVED0[LED] =~LED; 

    OK a few things here

    • First this is also obviously wrong since it does not include the required looping. Yes you can unroll but that can only go so far
    • Second have you tested? As I noted there is more going on than the instructions. Even just in the microprocessor before we get to the peripherals. It's been my experience that in micros like the ARMs toggle speed is limited by other than instruction timing.

    Robert

  • So you think at some point single cycle instructions would run in single cycles? The mcu will just eat some of them randomly?...
  • Danny F said:
    So you think at some point single cycle instructions would run in single cycles? The mcu will just eat some of them randomly?...

    Silly man, where did I ever imply that?

    No, there are other factors that slow instructions down. Pipeline effects, cache effects, peripheral timing. I'm sure there are more.

     Robert

  • Ok. Let's say that there are - obviously there are, like a pins current drive....

    But do you think those instructions will arrive at the port in the same order as issued by the core? Will the instructions cause the pins to swing, albeit may not sufficiently? But they will swing nonetheless. No?

    Would it be logical to think that if the pins can swing at 40Mhz when driven by a peripheral, the pins have the ability to swing at 40Mhz when driven by the core?
  • Danny F said:
    obviously there are, like a pins current drive....

    Try rephrasing that

    Danny F said:
    But do you think those instructions will arrive at the port in the same order as issued by the core?

    Instructions don't arrive at the port. I think I understand what you are trying to say. The outputs will arrive at the port in the same order that the instructions execute*. The timing of that may be restricted by things other than the instruction cycle count, extra cycles may be inserted.

    Danny F said:
    Will the instructions cause the pins to swing, albeit may not sufficiently?

    Yes

    Danny F said:
    Would it be logical to think that if the pins can swing at 40Mhz when driven by a peripheral, the pins have the ability to swing at 40Mhz when driven by the core?

    No. It's quite routine to observe otherwise actually. The peripheral will bypass the port structure and connect directly with the pin drivers**. As such the peripheral can have a quite different rate limit than the port.

    Robert

    * I'll even grant that in this case the instruction will execute in the order written.

    ** I don't think I've ever come across a device that multiplexes the pin drivers.

  • So it ***can*** have. But does it have?
  • Danny F said:
    So it ***can*** have. But does it have?

    What can have what? Words are your friend, there is no shortage.

    Robert