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.

TM4C1294NCPDT: TM4C1294NCPDT UART3

Part Number: TM4C1294NCPDT
Other Parts Discussed in Thread: ADS1243

Hi

I have designed my own board using  TM4C1294NCPDT.

I have checked UART0, UART2 and UART4 interrupts and they are working fine.

But I am facing problem with UART3. program stuck at uart3_init function.

Init function and interrupt handler functions are same as other working UARTs

The functions are as follows:

//******************************************************************

void uart3_init(uint32_t ui32SysClock)
{
//
// PJ0-1 are used for UART3.
//
ROM_GPIOPinConfigure(GPIO_PJ0_U3RX);
ROM_GPIOPinConfigure(GPIO_PJ1_U3TX);
ROM_GPIOPinTypeUART(GPIO_PORTJ_BASE, GPIO_PIN_0 | GPIO_PIN_1);

// already enabled GPIO Port D.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART3);

//
// Configure the UART for 115,200, 8-N-1 operation.
//
ROM_UARTConfigSetExpClk(UART3_BASE, ui32SysClock, 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));

//
// Enable the UART interrupt.
//
ROM_IntEnable(INT_UART3);
ROM_UARTIntEnable(UART3_BASE, UART_INT_RX | UART_INT_RT);
}

//******************************************************************

void uart4_init(uint32_t ui32SysClock)
{
//
// PA2-3 are used for UART4.
//
ROM_GPIOPinConfigure(GPIO_PA2_U4RX);
ROM_GPIOPinConfigure(GPIO_PA3_U4TX);
ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_3);

// already enabled GPIO Port A.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART4);

//
// Configure the UART for 115,200, 8-N-1 operation.
//
ROM_UARTConfigSetExpClk(UART4_BASE, ui32SysClock, 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));

//
// Enable the UART interrupt.
//
ROM_IntEnable(INT_UART4);
ROM_UARTIntEnable(UART4_BASE, UART_INT_RX | UART_INT_RT);
}

//******************************************************************

// The UART3 interrupt handler.

void UART3IntHandler(void)
{
uint32_t ui32Status;

//
// Get the interrupt status.
//
ui32Status = ROM_UARTIntStatus(UART3_BASE, true);

//
// Clear the asserted interrupts.
//
ROM_UARTIntClear(UART3_BASE, ui32Status);

//
// Loop while there are characters in the receive FIFO.
//
while(ROM_UARTCharsAvail(UART3_BASE))
{
//
// Read the character from the UART3 and write it to the UART4.
//
ROM_UARTCharPutNonBlocking(UART4_BASE,UARTCharGetNonBlocking(UART3_BASE));
}
}

//******************************************************************

// The UART4 interrupt handler.

void UART4IntHandler(void)
{
uint32_t ui32Status;

//
// Get the interrupt status.
//
ui32Status = ROM_UARTIntStatus(UART4_BASE, true);

//
// Clear the asserted interrupts.
//
ROM_UARTIntClear(UART4_BASE, ui32Status);

//
// Loop while there are characters in the receive FIFO.
//
while(ROM_UARTCharsAvail(UART4_BASE))
{
//
// Read the next character from the UART4 and write it back to the UART4.
//
ROM_UARTCharPutNonBlocking(UART4_BASE,UARTCharGetNonBlocking(UART4_BASE));
}
}

//******************************************************************

int main(void)
{
uint32_t ui32User0, ui32User1, ui32AnimPos, ui32Color;
uint8_t pui8MACArray[8],i;
tRectangle sRect;

//
// Run from the PLL at 120 MHz.
//
g_ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000);

//
// Configure the device pins.
//
init_pinconfig();
delay_ms(10);
uart0_init(g_ui32SysClock);
uart2_init(g_ui32SysClock);
uart3_init(g_ui32SysClock);
uart4_init(g_ui32SysClock);

while(1)

{

}

}

//******************************************************************

Also I have initialized required UART peripherals in init_pinconfig() function.

Can any one help for the UART3 communication problem?

  • Kiran,

    When you say that code gets stuck, it is a good idea if you let us know what is happening... Has it gone to a FAULT_ISR? Something else?

    That being said, did you enable the GPIO port in which the pins of your UART3 are located?

    Regards

    Bruno

  • Hello Bruno

    And we do see missing function prototypes...
  • Thanks Bruno,

    Thanks Amit,

    After enabling GPIO port pins  PJ0 and PJ1, solved the problem.

    Regards,

    Kiran 

  • Hello Kiran,

    But none of the GPIOs mentioned in the code have the clock enable...
  • Dear Amit,

    These are written in init_pinconfig() function

    void init_pinconfig()
    {
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOK);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOM);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOP);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOQ);

    GPIO_PORTA_AHB_DIR_R |= 0xC8; // Port A
    GPIO_PORTA_AHB_DEN_R |= 0xFC;

    GPIO_PORTB_AHB_DIR_R |= 0x34; // Port B
    GPIO_PORTB_AHB_DEN_R |= 0x34;

    GPIO_PORTC_AHB_DIR_R |= 0x30; // Port C
    GPIO_PORTC_AHB_DEN_R |= 0x30;

    GPIO_PORTD_AHB_DIR_R |= 0x20; // Port D
    GPIO_PORTD_AHB_DEN_R |= 0x3F;

    GPIO_PORTE_AHB_DIR_R |= 0x3C; // Port E
    GPIO_PORTE_AHB_DEN_R |= 0x3D;

    GPIO_PORTF_AHB_DIR_R |= 0x0C; // Port F
    GPIO_PORTF_AHB_DEN_R |= 0x0C;

    GPIO_PORTG_AHB_DIR_R |= 0x01; // Port G
    GPIO_PORTG_AHB_DEN_R |= 0x03;

    GPIO_PORTH_AHB_DIR_R |= 0x00; // Port H
    GPIO_PORTH_AHB_DEN_R |= 0x0F;

    GPIO_PORTJ_AHB_DIR_R |= 0x02; // Port J
    GPIO_PORTJ_AHB_DEN_R |= 0x03;

    GPIO_PORTK_DIR_R |= 0x9F; // Port K
    GPIO_PORTK_DEN_R |= 0xFF;

    GPIO_PORTM_DIR_R = 0xFF; // Port M
    GPIO_PORTM_DEN_R = 0xFF;

    GPIO_PORTN_DIR_R |= 0x3D; // Port N
    GPIO_PORTN_DEN_R |= 0x3F;

    GPIO_PORTP_DIR_R |= 0x04; // Port P
    GPIO_PORTP_DEN_R |= 0x04;

    GPIO_PORTQ_DIR_R |= 0x12; // Port Q
    GPIO_PORTQ_DEN_R |= 0x1A;

    delay_ms(1);
    /*
    GPIO_PORTC_AHB_DATA_R |= (0x20); // Output1
    GPIO_PORTC_AHB_DATA_R |= (0x10); // Output2
    GPIO_PORTK_DATA_R |= (0x04); // Output3
    GPIO_PORTK_DATA_R |= (0x08); // Output4
    GPIO_PORTK_DATA_R |= (0x01); // Output5
    GPIO_PORTK_DATA_R |= (0x02); // Output6
    GPIO_PORTB_AHB_DATA_R |= (0x10); // Output7
    GPIO_PORTE_AHB_DATA_R |= (0x04); // Output8

    */

    ROM_GPIOPinWrite(GPIO_PORTB_BASE, GPS, GPS_ON); //GPS supply enable

    ROM_GPIOPinWrite(GPIO_PORTN_BASE, SDI12, SDI12_DISABLE);

    ROM_GPIOPinWrite(GPIO_PORTK_BASE, ADC_PWR, ADC_ON); // ADC power enable
    ROM_GPIOPinWrite(GPIO_PORTK_BASE, ADC, ADC_DISABLE); // ADS1243 Disable


    ROM_GPIOPinWrite(GPIO_PORTQ_BASE, WIFI, WIFI_ON); // Wifi module power enable

    ROM_GPIOPinWrite(GPIO_PORTB_BASE, ICDI, ICDI_ON); // ICDI power enable

    ROM_GPIOPinWrite(GPIO_PORTA_BASE, LCD, LCD_ON); // LCD Module enable

    ROM_GPIOPinWrite(GPIO_PORTP_BASE, RS485, RS485_ON); // 5V Power enable
    ROM_GPIOPinWrite(GPIO_PORTN_BASE, RS485, RS485_RX_ENABLE); // RS485 RX Enable

    ROM_GPIOPinWrite(GPIO_PORTE_BASE, FLASH_PWR, FLASH_ON); // Enable Flash Supply
    ROM_GPIOPinWrite(GPIO_PORTQ_BASE, FLASH, FLASH_DISABLE); // MX66 Disable

    ROM_GPIOPinWrite(GPIO_PORTE_BASE, LED, LED_OFF); // User LED

    //
    // PF0/PF4-5/PH4/PQ0-2 are used for the SPI flash (on-board and SD card).
    // PH4 selects the SD card and PQ1 selects the on-board SPI flash.
    //
    ROM_GPIOPinConfigure(GPIO_PF0_SSI3XDAT1);
    // ROM_GPIOPinConfigure(GPIO_PF4_SSI3XDAT2);
    // ROM_GPIOPinConfigure(GPIO_PP1_SSI3XDAT3);
    ROM_GPIOPinConfigure(GPIO_PQ0_SSI3CLK);
    ROM_GPIOPinConfigure(GPIO_PQ2_SSI3XDAT0);

    ROM_GPIOPinTypeSSI(GPIO_PORTF_BASE, GPIO_PIN_0);

    ROM_GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_1);
    ROM_GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_1, GPIO_PIN_1);

    ROM_GPIOPinTypeSSI(GPIO_PORTQ_BASE, GPIO_PIN_0 | GPIO_PIN_2);

    ROM_GPIOPinTypeGPIOOutput(GPIO_PORTQ_BASE, GPIO_PIN_1);
    ROM_GPIOPinWrite(GPIO_PORTQ_BASE, GPIO_PIN_1, GPIO_PIN_1);
    }

    Regards,

    Kiran

  • Hello Kiran,

    Where have you configured the UART3 IO's (not sure if you are using PA4-PA5 pair or PJ0-PJ1 pair) for UART operations?

    Also it is not a good idea to use DRM. Rather use the TivaWare driverlib for IO initialization.
  • Hi Amit,

    I am using PJ0 and PJ1 port pins and mentioned in uart3_init() function.

    Is there any specific reason for not using DRM.

    This is given in example program, blinky. So I have stared using.

    Regards,

    Kiran

     

  • Hello Kiran,

    Using DRM makes the code more prone to error and is difficult for us to debug complex codes written by forum users/