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: I can only use Uart0(which uses PA0 and PA1),but when I changed to use other Uart(Uart1-7),they cannot work,I am really puzzled about it.

Part Number: TM4C123GH6PM
Other Parts Discussed in Thread: EK-TM4C123GXL

int main(void)
{

    SysCtlClockSet(SYSCTL_SYSDIV_1|SYSCTL_USE_OSC|SYSCTL_XTAL_16MHZ| SYSCTL_OSC_MAIN);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);


    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART3);

    GPIOPinConfigure(GPIO_PC6_U3RX);
    GPIOPinConfigure(GPIO_PC7_U3TX);
    GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_6 | GPIO_PIN_7);


    UARTConfigSetExpClk(UART3_BASE, SysCtlClockGet(), 9600,
                        (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |UART_CONFIG_PAR_NONE));

    UARTEnable(UART3_BASE);


    while(1)
    {

        SysCtlDelay(4000000);

        sprintf(send,"hi man this is tiva\r\n");

        i = 0;

        while(send[i]!='\0')
        {
            UARTCharPut(UART3_BASE, send[i]);
            i++;
        }
   }

}

  • The issue is with the use of sprintf(). I suspect it is the lack of heap space. I can look at it closer back in the office on Monday. The UART works. Try;

    #include <stdint.h>
    #include <stdbool.h>
    #include <stdio.h>
    #include "inc/hw_types.h"
    #include "inc/hw_memmap.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/gpio.h"
    #include "driverlib/uart.h"
    #include "driverlib/pin_map.h"
    
    int main(void)
    {
        unsigned int i;
        const char send[] = "hi man this is tiva\r\n\0";
    
        SysCtlClockSet(SYSCTL_SYSDIV_1|SYSCTL_USE_OSC|SYSCTL_XTAL_16MHZ| SYSCTL_OSC_MAIN);
    
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
    
    
        SysCtlPeripheralEnable(SYSCTL_PERIPH_UART3);
    
        GPIOPinConfigure(GPIO_PC6_U3RX);
        GPIOPinConfigure(GPIO_PC7_U3TX);
        GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_6 | GPIO_PIN_7);
    
    
        UARTConfigSetExpClk(UART3_BASE, SysCtlClockGet(), 9600,
                            (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |UART_CONFIG_PAR_NONE));
    
        UARTEnable(UART3_BASE);
    
    
        while(1)
        {
    
            SysCtlDelay(4000000);
    
            i = 0;
    
            while(send[i]!='\0')
            {
                UARTCharPut(UART3_BASE, send[i]);
                i++;
            }
       }
    
    }
    

  • It looks like you found the issue. (Post: https://e2e.ti.com/support/microcontrollers/other/f/908/t/820259). Yes, only UART0 is attached to the virtual serial port on the EK-TM4C123GXL launchpad. To connect the other UARTs to a PC requires the proper driver chips (RS232 for example) and computer port.

  • Hi,Bob,I remembered that you said sprintf was likely not very good ,I don't kown why I can't use sprintf and printf in CCS,can you explain it to me?

    and I post another question about interrupt of Uart,RE: TM4C123GH6PM: I am curious about when the uart Interrupt start to work,is it after UARTCharPut() finishes?,Can you help me see it?

    Hope you can understand my chinese English,hhh.Thank you very much.

  • Printf() and sprintf() can be used on the TM4C devices but they require large amounts of stack and heap. The default values used in the example programs that use UARTprintf() are insufficient for the full printf() functionality. Here is a post that has links explaining it more:

    https://e2e.ti.com/support/microcontrollers/other/f/908/t/819188

    When the transmit interrupt occurs is configurable. On page 901 of the datasheet it defines the transmit interrupt occurring as:

    So to answer your question, it depends on (1) if FIFO mode is being used, (2) what level the FIFO interrupt is set for, or (3) if EOT bit is set. By default at reset, the FIFO is not enabled and EOT is not set. The UART acts as a double buffered UART. The first call to UARTCharPut() will put the character in the buffer. The function will return immediately and the character immediately gets transferred to the shift register. The buffer is now empty, so a TX interrupt occurs (if enabled) ready for the next character. The next call to UARTCharPut() (if called before the shift buffer has emptied) will put the second character in the buffer and return. This time, no interrupt happens until the shift buffer empties and the second character is transferred from the buffer to the shift register.

  • Thank you for your kind help,Bob.

  • Greetings (again) Mr. Wang,

    Vendor's Bob has (once more) 'dug-deep' - and provided you 'key operational details' - which enable your issue's resolution.

    My young staff (and I) recognize your (continuing) Desire to Learn - and to 'master' these complex  ARM MCUs.

    To that end - may we suggest several of our 'methods (and/or madness)' which (most often) have worked well?

    • Bob 'gleaned his response' from his experience PLUS the MCU's (crucial & Subject Focused) Data Manual.    It is unclear if you had made similar recognition of the 'Vast Data' available - w/in the MCU Manual's 'FOCUSED, Peripheral Subject Areas'
    • Your studies will be immensely aided (we believe) by your making the time/effort to Print  those, 'Key MCU,  Peripheral Register Details.'    Print enables you to 'simultaneously view' several key registers - which 'screen view' cannot achieve!    The resulting 'back/forth' (i.e. endless) scrolling - proves NOT your friend.
    • Staff (loves) to copy paste from the MCU Manual - to their own (individual) MCU Binders - which enable their:
      • Highlighting (bold, italic etc)
      • Coloring
      • addition of key notes - which enable 'comprehension' - even (weeks/months) later!

    We enforce (only) the use of 8.5 x 11 (inch) paper as such can be 'Easily & Properly Filed' and/or placed w/in a binder - further aiding learning & review.   Short 'scraps of paper - and/or envelopes - are 'difficult' to properly file - and being smaller - are subject to loss.    And - should a client (during a meeting)  discover 'his firm's project' - resident upon a 'scrap' - beware!

    Your desire is to be commended - focus upon such 'efficiency methods' and 'cementing (guaranteeing) your understanding' - is likely to, 'Speed, Ease & Enhance' your studies & achievement.    Allez!

  • Hello,Mr Cb1_mobile,I am really grateful for your patient and selfless help,is it your company's secret ? hhh.

      I am preparing for TI Cup in China.with your help,I must get  a good grade.thank you,Cb1.

  • Mr. Wang,

    Your writing displays great kindness - much appreciated by my (primarily) young staff (7) - as well as the 'old guard (3 > 45).'   In addition - our group regularly engages 'top-class': University Professors, Industry Experts, & proven 'creatives' - on an international basis - greatly 'leveraging/extending/enhancing' our firm's capabilities & especially achievements!

    Your 'choice of words' - especially 'patient & selfless' - very well conveys (delivers)  your,  Adeptness, Graciousness & Insatiable Curiosity.

    At some point (just as realized by the 'young staff' here)  - it proves important for you to consider 'Methods/Means - to Accelerate your Learning!'    Staff here have embraced the (mostly) single teacher - multiple student 'model.'    Not surprisingly - with the correct (smart & highly motivated) group - those students quickly 'rise' to, 'Teach Each Other' - and (even ... ok often) 'cb1' - their alleged teacher/trainer.

    Might you find - and/or develop such a (local) 'group?'    Even the famed 'Lone Ranger' (*) had a sidekick - going it 'alone' proves 'Not the best means to master Tech!'    Forum requests are (unable to provide) 'Instant Group Think/Analysis'  and/or the oft required 'System Mastery' (beyond the MCU) - both practiced (daily) here ('chez cb1's - well appointed, back room'!)    Such responsive & skilled 'group' (formed perhaps by you as well) surely accelerates & reinforces Learning...

    (*)  Lone Ranger was a (past) U.S. western (law enforcement) radio, then  TV 'character' - who 'Sat atop the ratings...'   He was (immensely) aided by his (American Indian) partner, Tonto.   As (even they) noted - it proves advantageous to, 'Divide & somewhat Balance'  - the workload.

  • Hi,Bob,I  want to know how you got this picture ,could you teach me?

    https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/908/2465.Capture.PNG

  • Hello,Mr Cb1,I am really thankful for your careful and considerate help,I am grade 3 in Shanghai JiaoTong University China,I am really suprised and  honored to get so warm suggetions  from  abroad,During the summer vacation, I can have more free time to learn more from you,My foreign friends.Thank you again,and thank Bob.

    Wang liguo  In laboratory

  • Hi,

    I used a USB based logic analyzer / protocol analyzer. The one I have is the Intronix Logicport. It is a bit old. I think it cost about $400 US. There are several brands available. Just do a Web search of "USB Logic Analyzer".

  • Bob,$400,......expensive for me,hhh.

    could you help me In this question TM4C123GH6PM: _IQNtoF transform an IQ number to a float,But I cannot get the correct result,

    Ralph also replies to me.