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.

UART channel other than 0 is not working

Other Parts Discussed in Thread: EK-TM4C1294XL

Device: EK-TM4C1294XL

Project: Based off of timers example project

The example works fine for UART0.  When I modify it for another UART channel, execution stops on the following statement:

UARTprintf("\033[2JTimers example\n");

See code snippet below...

int
main(void)
{
//
// Set the clocking to run directly from the crystal at 120MHz.
//
g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN |
SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480), 120000000);

//
// Initialize the UART and write status.
//
ConfigureUART();

UARTprintf("\033[2JTimers example\n");  //does not return from this statement
UARTprintf("T1: 0 T2: 0");

//
// Enable the GPIO port that is used for the on-board LEDs.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);

//
// Enable the GPIO pins for the LEDs (PN0 & PN1).
//
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_0 | GPIO_PIN_1);


//
// Enable the peripherals used by this example.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);

//
// Enable processor interrupts.
//
ROM_IntMasterEnable();

//
// Configure the two 32-bit periodic timers.
//
ROM_TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);
ROM_TimerConfigure(TIMER1_BASE, TIMER_CFG_PERIODIC);
ROM_TimerLoadSet(TIMER0_BASE, TIMER_A, g_ui32SysClock);
ROM_TimerLoadSet(TIMER1_BASE, TIMER_A, g_ui32SysClock / 2);

//
// Setup the interrupts for the timer timeouts.
//
ROM_IntEnable(INT_TIMER0A);
ROM_IntEnable(INT_TIMER1A);
ROM_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
ROM_TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT);

//
// Enable the timers.
//
ROM_TimerEnable(TIMER0_BASE, TIMER_A);
ROM_TimerEnable(TIMER1_BASE, TIMER_A);

//
// Loop forever while the timers run.
//
while(1)
{
}
}

void
ConfigureUART(void)
{
RT for console I/O.
// //
//// UARTStdioConfig(0, 115200, g_ui32SysClock);
// UARTStdioConfig(0, 19200, g_ui32SysClock);

//
// Enable the GPIO Peripheral used by the UART.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

//
// Enable UART0.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART4);
while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_UART4)));

//
// Configure GPIO Pins for UART mode.
//
ROM_GPIOPinConfigure(GPIO_PA2_U4RX);
ROM_GPIOPinConfigure(GPIO_PA3_U4TX);
ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_3);

//
// Initialize the UART for console I/O.
//
UARTStdioConfig(4, 19200, g_ui32SysClock);

}

  • UARTprintf("\033[2JTimers example\n");


    I continued stepping after entering the above function and determined that the following function does not return:
    MAP_UARTCharPut(g_ui32Base, pcBuf[uIdx]);

  • I don't believe you ever configure stdio to use uart 4.

    BTW 'Past Code' makes it a lot easier to read. It adds colour coding and more importantly preserves indenting.

    Robert
  • This example is for UART3.  Has the same issue.

    Please change the extension from .txt to .exe to extract.

    timers_custom.txt

  • I don't download code

    Robert
  • Amit or one of the other TI reps might

    Robert
  • You don't read code snippets and you don't download code.  I am not sure what I should do at this point.

  • May I rise to the defense of (always) helpful poster, Robert?

    Downloading (unknown) code from an equally (unknown) source presents grave danger - many (most) serious organizations disallow that!

    Robert (did) suggest the means to make your code (far) easier to read/present here:

    "BTW 'Paste Code' makes it a lot easier to read. It adds colour coding and more importantly preserves indenting."  (that, "Says it All - does it not?)

    You must select, "Use Rich Formatting" - which appears at the right/bottom of your posting window.   Then click the 3rd icon "</>" from the right, bottom row of forum entry options.   Forum management rejects the introduction of "Poster Guidelines" which surely would assist many posters - especially those new here.   The info I've supplied is here (somewhere).   Instead - we (always) note the crystal clear ability to find "Blogs, Groups, Videos" - but NEVER ... VITAL/REQUIRED TechInfo!   "Why is that" should be a question, "more should ask - even demand!"

    It is normal for "Standard Output" to limit the number of UARTs which can be accessed.   That may explain your issue.

  • cb1 thank you for the details.  Using paste code for UART3



    void
    ConfigureUART(void)
    {
        //
        // Enable the GPIO Peripheral used by the UART.
        //
    //    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    //
    //    //
    //    // Enable UART0.
    //    //
    //    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
    //
    //    //
    //    // Configure GPIO Pins for UART mode.
    //    //
    //    ROM_GPIOPinConfigure(GPIO_PA0_U0RX);
    //    ROM_GPIOPinConfigure(GPIO_PA1_U0TX);
    //    ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    //
    //    //
    //    // Initialize the UART for console I/O.
    //    //
    ////    UARTStdioConfig(0, 115200, g_ui32SysClock);
    //    UARTStdioConfig(0, 19200, g_ui32SysClock);
    
    	//
    	// Enable the GPIO Peripheral used by the UART.
    	//
    	ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    
    	//
    	// Enable UART0.
    	//
    	ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART3);
    	while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_UART3)));
    
    	//
    	// Configure GPIO Pins for UART mode.
    	//
    	ROM_GPIOPinConfigure(GPIO_PA4_U3RX);
    	ROM_GPIOPinConfigure(GPIO_PA5_U3TX);
    	ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_4 | GPIO_PIN_5);
    
    	//
    	// Initialize the UART for console I/O.
    	//
    	UARTStdioConfig(3, 19200, g_ui32SysClock);
    
    }
    
    //*****************************************************************************
    //
    // This example application demonstrates the use of the timers to generate
    // periodic interrupts.
    //
    //*****************************************************************************
    int
    main(void)
    {
        //
        // Set the clocking to run directly from the crystal at 120MHz.
        //
        g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
                                                 SYSCTL_OSC_MAIN |
                                                 SYSCTL_USE_PLL |
                                                 SYSCTL_CFG_VCO_480), 120000000);
    
        //
        // Initialize the UART and write status.
        //
        ConfigureUART();
    
        UARTprintf("\033[2JTimers example\n");
        UARTprintf("T1: 0  T2: 0");
    
        //
        // Enable the GPIO port that is used for the on-board LEDs.
        //
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
    
        //
        // Enable the GPIO pins for the LEDs (PN0 & PN1).
        //
        ROM_GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    
    
        //
        // Enable the peripherals used by this example.
        //
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
    
        //
        // Enable processor interrupts.
        //
        ROM_IntMasterEnable();
    
        //
        // Configure the two 32-bit periodic timers.
        //
        ROM_TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);
        ROM_TimerConfigure(TIMER1_BASE, TIMER_CFG_PERIODIC);
        ROM_TimerLoadSet(TIMER0_BASE, TIMER_A, g_ui32SysClock);
        ROM_TimerLoadSet(TIMER1_BASE, TIMER_A, g_ui32SysClock / 2);
    
        //
        // Setup the interrupts for the timer timeouts.
        //
        ROM_IntEnable(INT_TIMER0A);
        ROM_IntEnable(INT_TIMER1A);
        ROM_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
        ROM_TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
    
        //
        // Enable the timers.
        //
        ROM_TimerEnable(TIMER0_BASE, TIMER_A);
        ROM_TimerEnable(TIMER1_BASE, TIMER_A);
    
        //
        // Loop forever while the timers run.
        //
        while(1)
        {
        }
    }

  • I'm no expert w/this vendor's UARTs but (sometimes) luck shines:

    • as stated earlier, your "UARTStdioConfig(3..."  does this vendor's implementation of UARTStdio (extend) to UART_3?   (often UART_2 is last (naturally) supported)
    • you violate KISS w/the introduction of the Timer aspect of your code.  (and you're not alone)  Would it not simplify things to focus (thus limit) your program to one "battlefield" at a time?   Solve the UART first - only then shift attention to the Timer.
    • often it proves easier to employ the API's UART functions (NOT Stdio) to succeed.   You may wish to try.   In doing so - code examples for Port_A (may) neglect some aspects of UART set-up & config as Port A's UART operates by default - which eliminates the need for (some) function calls.   (that decision by the vendor (employ a defaulting peripheral as an example) proves (most) unwise - to firm/my mind!)   Yet - even identified - continues...

  • Thanks to cb1 for expanding on my comment, also keep in mind Vincent many of us are here as volunteers and thus our time to help is limited.

    And as cb1 noted, my downloading of a strange exe would be most severely frowned upon.

    I suspect cb1 is correct as to the source of your issue as well. Do a search and I think you wil come up with others having similar issues.

    Your UARTStudioConfig function doesn't show up in my TIVAWare documentation so I can't help further on that.

    Just a passing note, I do not use stdio functions in embedded code, they are generally ill-suited to the task.

    Robert
  • Thanks to both cb1 and Robert for taking the time to respond.

    Stated in my original post:

    "Project: Based off of timers example project"

    I appreciate all the comments on how the code can be improved.  It is a good learning experience.  Since the code is basically TI's example code, I am sure they will benefit from your insights as well.

    As to my original issue, 

    "I continued stepping after entering the above function and determined that the following function does not return:
    MAP_UARTCharPut(g_ui32Base, pcBuf[uIdx]);"

    It appears that the problem is not with Stdio, but rather a Tivaware API.  Is there anyone knowledgeable that can assist and answer as to what might be happening here?

    Help on this would be greatly appreciated.

  • This vendor is not (fond) of KISS. As a result - many, many wind up here. Good luck w/your vendor "mix."

    Adoption by vendor of (outsider's) suggestion (NIH) has all the chance of HMS Titanic (evading) iceberg...
  • Vincent Gagliardo said:

    "I continued stepping after entering the above function and determined that the following function does not return:
    MAP_UARTCharPut(g_ui32Base, pcBuf[uIdx]);"

    It appears that the problem is not with Stdio, but rather a Tivaware API.

    Possible, but not demonstrated. Suggestion:

    Check that the call actually uses the UART you think it should. The first argument is the address of the UART, check that it is correct. (compare it against UART3_BASE in your latest example).

    Also if the stdio configure function has an error return make sure you check that.

    Robert

  • Robert,

    You were right about the API. It only supports UART bases 0 thru 2. I modified it to include bases 0 thru 7 and its responding.

    Thanks for your help.
  • cb1- said:
    It is normal for "Standard Output" to limit the number of UARTs which can be accessed.   That may explain your issue.

    While awarding "Verifies en masse" should not the true (first) poster mention receive (his) rightful award?

  • cb1, you were certainly helpful on this and contributed to help with my lack of knowledge of posting code. However, I wasn't sure what to make of "standard output" and how to trace that to a solution.

    In the end, it was Robert's details that led to the final solution.
  • Ok - I'm not (that) upset. Rest easy - pay (no) attention to my lifeless, hanging body - swinging from forum gallows...

  • cb1- said:
    as stated earlier, your "UARTStdioConfig(3..."  does this vendor's implementation of UARTStdio (extend) to UART_3?   (often UART_2 is last (naturally) supported)

    Staff (not the devil) made me do it!   (present the far earlier quote - which rings crystal clear to staff/me - yet (apparently) not to poster Vincent.

    Poster reports he, "Didn't know what to make of this writing."   Presented here (again) for ALL to see!

    Pity that - justice withheld is justice unserved...   (in days past a vendor rep would CORRECT such injustice!)

  • cb1, my apologies as I missed your original statement above. Has your perspective of justice now been served?
  • Vincent - justice should be (universal & sound) thus individual perspectives are of lesser consequence. The weight of the evidence herein argued for the action you've (now) taken. It is appreciated...   (btw - "my" perspective of justice - formed/advised @ UCLA law - likely proves sound...)