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.

Problem configuring UART3 on LM4F232H5QD revision A3

Other Parts Discussed in Thread: TM4C129DNCPDT

I am experiencing an issue whilst trying to debug UART3 on an LX4F232H5QD revision A3.  I am using an XDS100V2 and CCS5.4 under Linux.

The following code for UART2 works successfully when debugging with the JTAG connected.  Similar code also works successfully for UART0 and UART1 also:

else if(uart_number==2)
    {
        //PG5 - U2Tx
        //PG4 - U2Rx
        //PH5 - RS485/!RS232_UART0
        //PH4 - HDPLX_UART0
        //PH3 - RS/!TTL_UART0
        //PK6 - UART0_TX/!RX

        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH);                                    //enable PORT H
        GPIOPinTypeGPIOOutput(GPIO_PORTH_BASE, GPIO_PIN_5|GPIO_PIN_4|GPIO_PIN_3);        //set PH5, PH4 and PH3 as outputs
        GPIOPinWrite(GPIO_PORTH_BASE, GPIO_PIN_5|GPIO_PIN_4|GPIO_PIN_3, ((0x01<<5)|(0x01<<4)|(0x01<<3)));    //write 1 only to PH5, PH4 and PH3
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOK);                                    //enable PORT K
        GPIOPinTypeGPIOOutput(GPIO_PORTK_BASE, GPIO_PIN_6);                                //set PK6 as output
        GPIOPinWrite(GPIO_PORTK_BASE, GPIO_PIN_6, 0x0);                                    //write 0 only to PK6
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);                                    //enable PORT G
        SysCtlPeripheralEnable(SYSCTL_PERIPH_UART2);                                    //enable UART 2
        GPIOPinConfigure(GPIO_PG4_U2RX);                                                //Set alternate pin configuration
        GPIOPinConfigure(GPIO_PG5_U2TX);                                                //Set alternate pin configuration
        GPIOPinTypeUART(GPIO_PORTG_BASE, GPIO_PIN_5 | GPIO_PIN_4);                        //Configure UART pins as PG5 and PG4
        sysclk=SysCtlClockGet();                                                        //Get system clock speed
        UARTConfigSetExpClk(UART2_BASE, sysclk, uart_speed,(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));    //Configure UART2
        UARTFIFODisable(UART2_BASE);                                                    //Disable FIFO
        UARTIntEnable(UART2_BASE, UART_INT_RX);                                            //Disable RX interrupt
        IntEnable(INT_UART2);                                                            //enable UART2 interrupt
        IntMasterEnable();                                                                //enable interrupts
    }
    else if(uart_number==3)
    {
        //PC7 - U3Tx
        //PC6 - U3Rx
        //PJ0 - RS485/!RS232_UART0
        //PH7 - HDPLX_UART0
        //PH6 - RS/!TTL_UART0
        //PK7 - UART0_TX/!RX

        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH);                                    //enable PORT H
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ);                                    //enable PORT J
        GPIOPinTypeGPIOOutput(GPIO_PORTH_BASE, GPIO_PIN_7|GPIO_PIN_6);                    //set PH7, PH6 as outputs
        GPIOPinTypeGPIOOutput(GPIO_PORTJ_BASE, GPIO_PIN_0);                                //set PJ0 as an output
        GPIOPinWrite(GPIO_PORTH_BASE, GPIO_PIN_7|GPIO_PIN_6, ((0x01<<7)|(0x01<<6)));    //write 1 only to PH7, PH6
        GPIOPinWrite(GPIO_PORTJ_BASE, GPIO_PIN_0, (0x01<<0));                            //write 1 only to PJ0
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOK);                                    //enable PORT K
        GPIOPinTypeGPIOOutput(GPIO_PORTK_BASE, GPIO_PIN_7);                                //set PK7 as output
        GPIOPinWrite(GPIO_PORTK_BASE, GPIO_PIN_7, 0x0);                                    //write 0 only to PK7
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);                                    //enable PORT C
        SysCtlPeripheralEnable(SYSCTL_PERIPH_UART3);                                    //enable UART 3
        GPIOPinConfigure(GPIO_PC6_U3RX);                                                //Set alternate pin configuration
        GPIOPinConfigure(GPIO_PC7_U3TX);                                                //Set alternate pin configuration
        GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_7 | GPIO_PIN_6);                        //Configure UART pins as PC6 and PC7
        sysclk=SysCtlClockGet();                                                        //Get system clock speed
        UARTConfigSetExpClk(UART3_BASE, sysclk, uart_speed,(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));    //Configure UART3
        UARTFIFODisable(UART3_BASE);                                                    //Disable FIFO
        UARTIntEnable(UART3_BASE, UART_INT_RX);                                            //Disable RX interrupt
        IntEnable(INT_UART3);                                                            //enable UART3 interrupt
        IntMasterEnable();                                                                //enable interrupts
    }

However, UART3 gets stuck in a loop when the JTAG is connected.  The loop that it gets stuck in UARTDisable which is called from UARTConfigSetExpClk.

Strangely though, when the JTAG is not connected, it works correctly.

Has anybody experienced anything similar?

Thanks

Lee

  • Interesting - and applaud your systematic, parallel, UART port management & presentation.

    Haven't the time now to check deeper - but hazard the guess that GPIOPinTypeUART() is most likely suspect. (realize that this is a, "long-shot" - but is w/in realm of possibility - and we don't have much else...)   Believe that someway/somehow PC0-PC3 are impacted by that function.  Your review of Port C's register status via your IDE - both pre & post the call to, "GPIOPinTypeUART()" - should cast some diagnostic light - this issue.   

    It may be possible that the lack of external, JTAG pull-up R's - are cause agent/contributor.  (attachment -> working - when JTAG probe attaches - my logic basis)

    Update: 09 Sept 09:13 CST - just checked driverlib - both PinType() & PinConfigure() properly confine their operation to the masked bits.  (as expected)  And - the fact that other UART Ports do behave - w/and w/out JTAG probe (we assume) adds further mystery.  Did note that the selection matrix for UART3 is 1 - which also is used by "normal" JTAG for PC0-PC3.  Register examination seems most critical now...

     

  • Morning cb1_mobile

    Firstly, thanks for taking the time to respond to my request for help.

    I have managed to get to the bottom of what is happening and resolve the problem.  It seems that the device is not being fully reset by CCS (i.e. all registers - I have only checked the UART registers) to it's default power-on state when connected to the XDS100.  This is in spite of the relevant settings being set in the project Properties->Run/Debug Settings->Target->Program/Memory Load Options.  I noticed that the UARTFR register was reset to 0x38(TXFF, RXFE and BUSY) when it should have been 0x90.

    With the BUSY bit being set, the call to UARTDisable gets stuck at:

        while(HWREG(ulBase + UART_O_FR) & UART_FR_BUSY)
        {
        }

    This appears to be an emulator issue as the device works as expected without the emulator connected.

    A fix to this is to use the following code at the beginning of main() to perform a software reset of the device:

        if(SysCtlResetCauseGet() & SYSCTL_CAUSE_SW)
        {
            SysCtlResetCauseClear(SYSCTL_CAUSE_SW);
        }
        else
        {
            SysCtlReset();
        }

  • Hi,

    Even I faced the same problem on TM4C129DNCPDT with XDS200. I tried Lee Stanton's fix. But mostly mine started working when I just cycled the power. 

     

    Here is my code just in case: 

     

    #include <stdint.h>
    #include <stdbool.h>
    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "driverlib/debug.h"
    #include "driverlib/fpu.h"
    #include "driverlib/gpio.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/uart.h"
    #include "utils/uartstdio.h"
    
    char cIliad[] = "La la la hey hey";
    
    #ifdef DEBUG
    void
    __error__(char *pcFilename, uint32_t ui32Line)
    {
    }
    #endif
    
    void ConfigureUART(void) {
    
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    
        SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
    
        GPIOPinConfigure(GPIO_PA0_U0RX);
        GPIOPinConfigure(GPIO_PA1_U0TX);
        GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    
        UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);
    
        UARTStdioConfig(0, 115200, 16000000L);
    }
    
    int main(void) {
    
    	//Issue http://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/p/289292/1008849.aspx
    //	if(SysCtlResetCauseGet() & SYSCTL_CAUSE_SW)	{
    //		SysCtlResetCauseClear(SYSCTL_CAUSE_SW);
    //	} else {
    //		SysCtlReset();
    //	}
    
        FPULazyStackingEnable();
    
        SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ |SYSCTL_OSC_MAIN);
    
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOM);
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);
        GPIOPinTypeGPIOOutput(GPIO_PORTM_BASE, GPIO_PIN_7);
        GPIOPinTypeGPIOOutput(GPIO_PORTL_BASE, GPIO_PIN_5);
    
    
        ConfigureUART();
    
        UARTprintf(cIliad);
    
        while(1) {
    		GPIOPinWrite( GPIO_PORTM_BASE,GPIO_PIN_7,GPIO_PIN_7);
    	    GPIOPinWrite( GPIO_PORTL_BASE,GPIO_PIN_5,GPIO_PIN_5);
    
            SysCtlDelay(16000000 / 10 / 3);
    
    		GPIOPinWrite( GPIO_PORTM_BASE,GPIO_PIN_7,0);
    		GPIOPinWrite( GPIO_PORTL_BASE,GPIO_PIN_5,0);
    
            SysCtlDelay(16000000 / 10 / 3);
        }
    }
    

     

  • Anurag Chugh said:
    char cIliad[] = "La la la hey hey";

    While traditionally attributed to Homer - if that lyric meets, "dactylic hexameter," spec - my tin ear may have progressed to stone...

  • haha! where the "like" button at?

    Didnt think i was going to publish the code. The irony was reserved only for my misbehaving microcontroller board.

  • Anurag Chugh said:
    where the "like" button at?

    Yet another, "satisfied customer..."   Your "publication" likely will lure friend Roberto - who's recently witnessed the  misbehaved descent of Icarus.  (indeed - little need to debug (we're told) - or craft well-adhering control & lift surfaces...)  {may be a tad too "inside" - but should warrant double, "like."}