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 with UART



Hello, I'm trying to use UART2 but the application hangs after "UARTStdioInit(2);" instruction and I don't know why. Here is my code:

void main (void){

SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART2);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
HWREG(GPIO_PORTD_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD;
HWREG(GPIO_PORTD_BASE + GPIO_O_CR) = 0x80;
GPIOPinConfigure(GPIO_PD7_U2TX);
GPIOPinTypeUART(GPIO_PORTD_BASE, GPIO_PIN_7);
GPIOPinConfigure(GPIO_PD6_U2RX);
GPIOPinTypeUART(GPIO_PORTD_BASE, GPIO_PIN_6);
UARTStdioInit(2);
SysCtlDelay(20000000);


while(1){
UARTprintf("Hello World!\n");
SysCtlDelay(200000);
}
}

Thank you!

  • TEstet said:
    the application hangs after "UARTStdioInit(2);" instruction

    Note that's not an "instruction" - it's a function call.

    Have you used the debugger to step throught the code to see exactly where it's hanging?

  • Hi, I'm no expert, but I have had this problem. I agree with Andy, use the debugger to step into UARTStdioInit() and then look to see exactly what file you're in - I found I was in an old version of this function in another project for some reason, so removed all "evaluation projects" from my workspace and checked the linker paths (which seemed ok to me) and all ran fine. HTH

  • TEstet,

    Does similar code using UART0, PA0, and PA1 produce the same problem in your project? Try running the uart_echo example to see if the problem is isolated to your project.

    As the other posters have suggested, using the debugger to step into the function and find the exact line that triggers the fault would be helpful.

    Are you still using the Launchpad and CCS as in this thread?