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.

Launchpad with UART RX Problem



Hi 

I am using the UART interface to communicate RX/TX using Zigbee. I don't have a problem to send data but I don't receive anything. Somehow the UARTIntHandler(void) does not work and it does not detect incoming signals. Does anybody knows what may be the problem? 

My code that I use is below. Any help greatly appreciated.

Thank you

Damian

*************************************************************

include "inc/hw_ints.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/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"

int temp=0;

//*****************************************************************************
//
//! \addtogroup example_list//! <h1>UART Echo (uart_echo)</h1>A
//!
//! This example application utilizes the UART to echo text. The first UART
//! (connected to the USB debug virtual serial port on the evaluation board)
//! will be configured in 115,200 baud, 8-n-1 mode. All characters received on
//! the UART are transmitted back to the UART.
//
//*****************************************************************************
//*****************************************************************************//
// The error routine that is called if the driver library encounters an error.//
//*****************************************************************************
//#ifdef DEBUG
//void
//__error__(char *pcFilename, unsigned long ulLine)
//{
//}
//#endif


//*****************************************************************************
//
// The UART interrupt handler.
//
//*****************************************************************************
void
UARTIntHandler(void)
{
unsigned long ulStatus;
//
// Get the interrupt status.
//
ulStatus = ROM_UARTIntStatus(UART0_BASE, true);

//
// Clear the asserted interrupts.
//
ROM_UARTIntClear(UART0_BASE, ulStatus);
//
// Loop while there are characters in the receive FIFO.
//
while(ROM_UARTCharsAvail(UART0_BASE))
{
//
// Read the next character from the UART and write it back to the UART.
//
ROM_UARTCharPutNonBlocking(UART0_BASE,
ROM_UARTCharGetNonBlocking(UART0_BASE));

//
// Blink the LED to show a character transfer is occuring.
//
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2);

//
// Delay for 1 millisecond. Each SysCtlDelay is about 3 clocks.
//
SysCtlDelay(SysCtlClockGet() / (1000 * 3));
//
// Turn off the LED
//
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0);

}
}

//*****************************************************************************
//
// Send a string to the UART.
//
//*****************************************************************************
void
UARTSend(const unsigned char *pucBuffer, unsigned long ulCount)
{
//
// Loop while there are more characters to send.
//
while(ulCount--)
{
//
// Write the next character to the UART.
//
ROM_UARTCharPutNonBlocking(UART0_BASE, *pucBuffer++);
}
}

//*****************************************************************************
//
// This example demonstrates how to send a string of data to the UART.
//
//*****************************************************************************
int
main(void){
//
// Enable lazy stacking for interrupt handlers. This allows floating-point
// instructions to be used within interrupt handlers, but at the expense of
// extra stack usage.
//

ROM_FPUEnable();
ROM_FPULazyStackingEnable();

//
// Set the clocking to run directly from the crystal.
//

ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
//
// Enable the GPIO port that is used for the on-board LED.
//

ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
//
// Enable the GPIO pins for the LED (PF2).
//

ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2);
//
// Enable the peripherals used by this example.
//

ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
//
// Enable processor interrupts.
//

ROM_IntMasterEnable();
//
// Set GPIO A0 and A1 as UART pins.
//

ROM_GPIOPinConfigure(GPIO_PA0_U0RX);
ROM_GPIOPinConfigure(GPIO_PA1_U0TX);

ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
//
// Configure the UART for 9600, 8-N-1 operation.
//

ROM_UARTConfigSetExpClk(UART0_BASE, ROM_SysCtlClockGet(), 9600,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));
//
// Enable the UART interrupt.
//

ROM_IntEnable(INT_UART0);
ROM_UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT);

//
// Send 0 & 1.
//

while(1)
{
if(temp==1){
UARTSend((unsigned char *)"0", 1);
temp=0;
SysCtlDelay(6000000);
}

if(temp==0){
UARTSend((unsigned char *)"1", 1);
temp=1;
SysCtlDelay(6000000);
}

}
}

  • Damian Cieslicki said:
    Somehow the UARTIntHandler(void) does not work and it does not detect incoming signals.

    Have you modified the source file which contains the array of interrupt handlers to add UARTIntHandler for UART0?

    For a CCS project based upon the TivaWare examples there will be a startup_ccs.c source file and in the g_pfnVectors array you need to replace the IntDefaultHandler entry for UART0 with your UARTIntHandler.

    [The IntDefaultHandler justs causes the processor to enter an infinite loop if called.]

  • Hi Chester,

    Thank you for the answer. I have couple more questions, however.

    1. I did not modify the source file that contains the array of interrupt handlers. That's probably my first problem.

    2. I did not find startup_css.c in my project. However, this file exists in my other projects. Can I just copy it to my project and it will be automatically "detected" during compilation time?

    3. In startup_css.c file do I need to change only one line of code 

    IntDefaultHandler,                         // UART0 Rx and Tx      ->->-> to ->->->         UARTIntHandler,                         // UART0 Rx and Tx

    is this enough.

    My question is if the compiler will not complain that UARTIntHandler is not defined. Do I need to include some file etc.?

    Any help greatly appreciated. 

    Damian

  • Hi Chester,

    Since my last e-mail I did the following:

    1. I copied the startup_css,c file from different project.

    2. I actually changed two line of code:

    UARTIntHandler, // UART0 Rx and Tx
    UARTIntHandler, // UART1 Rx and Tx

    3. I defined the UARTIntHandler in this file:

    static void
    UARTIntHandler(void)
    {
    //
    // Go into an infinite loop.
    //
    while(1)
    {
    }
    }

    4. Everything compiles/runs but still the UARTIntHandler is not invoked. Did I miss something?

    thanks

    damian

  • Hi Damian,

    It seems that you did not use, uart_echo as base.

    Do you have this line below at your startup file?

    //*****************************************************************************
    //
    // External declaration for the interrupt handler used by the application.
    //
    //*****************************************************************************
    extern void UARTIntHandler(void);

    -kel

  • Markel,

    I didn't have this part in the startup_css.c. I added but still it does not break in UARTIntHandler

    Thanks

    Damian

  • Hi,

       Try connecting your UART to your PC, and see if you are able to perform a uart_echo, to check for any problems.

    -kel

  • Damian Cieslicki said:
    UART interface to communicate RX/TX using Zigbee. I don't have a problem to send data but I don't receive anything

    Do not note any mention of "level translators" - this series of posts.

    Should your external device employ RS232 signal levels - those far exceed MCU levels (any MCU) and it may be that UART_RX has, "left the building."

  • What you have done same problem please reply its urgent
  • Hello Harshal,

    It is better that you open a new post with the issue that you are facing clearly defined; rather than opening an older post.