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.

TM4C129XNCZAD: Interrupt driven Uart 1 reception problem

Part Number: TM4C129XNCZAD

Hi all im working in interupt driven uart reception for atlease 4 uarts in tm4c129xnczad micro controller, i have achieved the interupt reception uart for uart 0 like wise i tried the reception for uart1  where i could not get the character im sending through terminal, the ide i am using is code composer i have attached my code below any thoughts on this please let me know.

//********************************UART0_INITIALISATION  ************************//
void Uart0_Init(void)
{

	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

	MAP_GPIOPinConfigure(GPIO_PA0_U0RX);
	MAP_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0);


	MAP_GPIOPinConfigure(GPIO_PA1_U0TX);
	MAP_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_1);

	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

	MAP_UARTConfigSetExpClk(UART0_BASE, ui32SysClock, 115200,
					   (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
						UART_CONFIG_PAR_NONE));

	MAP_IntEnable(INT_UART0);
	MAP_UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT);

}


//********************************UART1_INITIALISATION  ************************//
void Uart1_Init(void)
{

	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

	MAP_GPIOPinConfigure(GPIO_PB0_U1RX);
	MAP_GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0);


	MAP_GPIOPinConfigure(GPIO_PB1_U1TX);
	MAP_GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_1);

	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);

	MAP_UARTConfigSetExpClk(UART1_BASE, ui32SysClock, 115200,
					   (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
						UART_CONFIG_PAR_NONE));

	MAP_IntEnable(INT_UART1);
	//MAP_UARTIntEnable(UART1_BASE, UART_INT_RX | UART_INT_RT);

}

//*****************************************************************************
//
// The UART interrupt handler.
//
//*****************************************************************************
void UART0IntHandler(void)
{
    uint32_t ui32Status;

   // MAP_UARTCharPutNonBlocking(UART0_BASE, input);
   // GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_4, GPIO_PIN_4);
    //
    // Get the interrrupt status.
    //
    ui32Status = MAP_UARTIntStatus(UART0_BASE, true);

    //
    // Clear the asserted interrupts.
    //
    MAP_UARTIntClear(UART0_BASE, ui32Status);

    //MAP_UARTCharPutNonBlocking(UART0_BASE,UARTCharGetNonBlocking(UART0_BASE));
    input = UARTCharGetNonBlocking(UART0_BASE);
    //
    // Loop while there are characters in the receive FIFO.
    //
    /*while(MAP_UARTCharsAvail(UART0_BASE))
    {
        //
        // Read the next character from the UART and write it back to the UART.
        //
        MAP_UARTCharPutNonBlocking(UART0_BASE,
                                   UARTCharGetNonBlocking(UART0_BASE));
    }*/
}


void UART1IntHandler(void)
{
    uint32_t ui32Status;

   // MAP_UARTCharPutNonBlocking(UART0_BASE, input);
   // GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_4, GPIO_PIN_4);
    //
    // Get the interrrupt status.
    //
    ui32Status = MAP_UARTIntStatus(UART1_BASE, true);

    //
    // Clear the asserted interrupts.
    //
    MAP_UARTIntClear(UART1_BASE, ui32Status);

    //MAP_UARTCharPutNonBlocking(UART0_BASE,UARTCharGetNonBlocking(UART0_BASE));
    input_1 = UARTCharGetNonBlocking(UART1_BASE);
    //
    // Loop while there are characters in the receive FIFO.
    //
    /*while(MAP_UARTCharsAvail(UART0_BASE))
    {
        //
        // Read the next character from the UART and write it back to the UART.
        //
        MAP_UARTCharPutNonBlocking(UART0_BASE,
                                   UARTCharGetNonBlocking(UART0_BASE));
    }*/
}






int main(void)
{
    volatile uint32_t ui32Loop;



    ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
                                               SYSCTL_OSC_MAIN |
                                               SYSCTL_USE_PLL |
                                               SYSCTL_CFG_VCO_240), 120000000);
        //ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);



    Uart0_Init();
    Uart1_Init();
    MAP_UARTCharPutNonBlocking(UART0_BASE, 'a');
    MAP_UARTCharPutNonBlocking(UART1_BASE, 'b');


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


    //
    // Check if the peripheral access is enabled.
    //
    while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPION))
    {
    }

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);



    //
    // Check if the peripheral access is enabled.
    //
    while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOF))
    {
    }
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOE))
    {
    }

    //
    // Enable the GPIO pin for the LED (PN0).  Set the direction as output, and
    // enable the GPIO pin for digital function.
    //
    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_4);
    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_3);
    GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_5);
    GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_6);
    /*PORTF_DIR |= 0x0000003E;    //set PF1, PF2, PF3 as output
    PORTF_DEN |= 0x0000003E;    //enable PF1, PF2, PF3
    PORTF_DATA = 0;*/

    //
    // Loop forever.
    //
    while(1)
    {
        //
        // Turn on the LED.
        //
    	//MAP_UARTCharPutNonBlocking(UART1_BASE, 'b');
    	if(input != 0)
    	{
    		MAP_UARTCharPutNonBlocking(UART0_BASE, input);
    		input = 0;
    	}
    	if(input_1 != 0)
		{
			MAP_UARTCharPutNonBlocking(UART1_BASE, input_1);
			input_1 = 0;
		}
    	/*if(GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_5))
    	{
    		GPIO_PORTF_AHB_DATA_R |= (GPIO_PIN_4);
    	}
    	else
    	{
    		GPIO_PORTF_AHB_DATA_R &= ~(GPIO_PIN_4);
    	}*/
       /* GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_4, GPIO_PIN_4);
        GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3, GPIO_PIN_3);
        GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_5, GPIO_PIN_5);
        GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_6, GPIO_PIN_6);*/


        //
        // Delay for a bit.
        //
       /* for(ui32Loop = 0; ui32Loop < 2000000; ui32Loop++)
        {
        }*/
    	// PORTF_DATA |= (GPIO_PIN_4 | PF2 | PF3);
       // SysCtlDelay(5000000);
        delayMs(200);
        //
        // Turn off the LED.
        //
      //  GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_4, 0x0);
        /*GPIO_PORTF_AHB_DATA_R &= ~((GPIO_PIN_4));
        GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3, 0x0);
        GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_6, 0x0);
        //PORTF_DATA &= ~(GPIO_PIN_4 | PF2 | PF3 );*/
        delayUs(100);
       // SysCtlDelay(5000000);
        //
        // Delay for a bit.
        //
       /* for(ui32Loop = 0; ui32Loop < 2000000; ui32Loop++)
        {
        }*/
    }

	return 0;
}



  • Hi,

      The reason is that in your Uart1_Init() you comment out the line to enable interrupt for RX. See line 46. Uncomment it and try again. Also make sure you have the interrupt vector for UART1IntHandler() in the vector table in startup_ccs.c file. 

  • Yes i tried with enabling it when i do that even my uart0 which was working is not working and also uart1 is not working when i enable it so i commented it. When this line is commented only then the uart1 tx is working fine and also the uart0 tx and rx is working fine that is the reason i commented that line.

  • First of all, in order to generate a RX interrupt, you must enable the interrupt. You must first uncomment the line and then debug what happen. Can you show a scope cap of UART1TX and UART1RX pins. Put a breakpoint on UART1IntHandler. 

    When this line is commented only then the uart1 tx is working fine and also the uart0 tx and rx is working fine that is the reason i commented that line.

    If uart1tx is fine then you must also check if you have uart1tx and uart1rx pins tied together if you are testing in a loopback fashion.

  • Thankyou for the support i enabled the commented line "MAP_UARTIntEnable(UART1_BASE, UART_INT_RX | UART_INT_RT);" and it worked for me and i think that due to hardware issues it was not working previously. Now its working as expected i will try uart 2 and uart3 and will update in this forum.