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 reception problem

Part Number: TM4C129XNCZAD


Hi all Im working on Interrupt driven uart reception in tm4c129xnczad microcontroller , im working in code composer studio the problem is im not getting the uart reception and the isr handler is not triggered, I have attached my code here below

Any tho

//*****************************************************************************
//
// The UART interrupt handler.
//
//*****************************************************************************
void
UARTIntHandler(void)
{
    uint32_t ui32Status;
    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);

    //
    // 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));
    }
}
//*****************************************************************************
//
// Send a string to the UART.
//
//*****************************************************************************
void
UARTSend(const uint8_t *pui8Buffer, uint32_t ui32Count)
{
    //
    // Loop while there are more characters to send.
    //
    while(ui32Count--)
    {
        //
        // Write the next character to the UART.
        //
        MAP_UARTCharPutNonBlocking(UART0_BASE, *pui8Buffer++);
    }
}


void delayMs(uint32_t ui32Ms) {

	// 1 clock cycle = 1 / SysCtlClockGet() second
	// 1 SysCtlDelay = 3 clock cycle = 3 / SysCtlClockGet() second
	// 1 second = SysCtlClockGet() / 3
	// 0.001 second = 1 ms = SysCtlClockGet() / 3 / 1000

	SysCtlDelay(ui32Ms * (120000000 / 3 / 1000));
}

void delayUs(uint32_t ui32Us)
{
	SysCtlDelay(ui32Us * (120000000 / 3 / 1000000));
}
int main(void)
{
    volatile uint32_t ui32Loop;
    uint32_t ui32SysClock;


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

        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);

        MAP_UARTCharPutNonBlocking(UART0_BASE, 'a');


    //
    // 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(UART0_BASE, 'a');
    	/*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);
        delayUs(100);
        //
        // 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;
}
ughts please share me

  • Hi,

      I think your code is based on the uart_echo from TivaWare, correct? I have some suggestions.

      -Please make sure uart_echo works as expected.

      - I don't see  MAP_IntMasterEnable() in your code. Please add it to enable processor level interrupt unless you have already enabled it somewhere else. 

      - You need to have a interrupt vector named UARTIntHandler plugged in the vector table. See below in startup_ccs.c file.

      - How are you connecting the UARTRX and UARTTX? If you are writing something to UARTTX and expecting to receive from UARTRX then make sure you have the PA0 and PA1 pins connected on your board. 

      - Change from MAP_UARTCharPutNonBlocking(UART0_BASE, 'a') to MAP_UARTCharPut(UART0_BASE, 'a');

  • "I think your code is based on the uart_echo from TivaWare, correct? " 

    yes im using uart echo code as base.

    " You need to have a interrupt vector named UARTIntHandler plugged in the vector table. See below in startup_ccs.c file."

    Thankyou so much this resolved my issue. I have to map the UARTIntHandler in the startup_ccs.c file.

    " I don't see  MAP_IntMasterEnable() in your code."

    Without adding this also the code is working fine when we should add the above Map_IntMasterEnable().

    Thankyou

  • Without adding this also the code is working fine when we should add the above Map_IntMasterEnable().

    Based upon a previous investigation in TM4C1294NCPDT: RTOS: BIOS not working, after a processor reset PRIMASK is already zero meaning interrupts are already globally enabled and a IntMasterEnable() call isn't required.

    The issue in the referenced thread was when using a boot loader, and the boot loader left interrupts globally disabled when transferring to the application and the application didn't have a IntMasterEnable() call.

  • Thankyou Chester Gillon for the valuable inputs.