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.

Uartprinf doesn't working



Hello, please, could someone help me?

I've been trying to use the UartPrinf function from utils/uartstdio.h, but ccs doesn't recognize the library function. 

I dont know what I need to do to correct use this library. 

When I run the TI examples, it works. But, If I try to write by myself, it doesn't...

I created a variable path called tiva_dir. It point to where I installed tivaware. The most weird is I can use, for example, driverlib without any problems. CCS can find it, but not the function I need.

This is the error. 

Description Resource Path Location Type

unresolved symbol UARTStdioConfig, first referenced in ./MiniStation.obj MiniStation C/C++ Problem

Thanks

  • Uartstdio is not part of the driverlib, it is in the utils folder with several other useful modules. By default, uartstdio.c is not compiled thus not linkable. You have to add uartstdio source and header files to your project with correct path links in project properties.
  • Hello, 

    Thanks for your answer. It helped me to understand one part of the problem.

    I want to use 2 uarts. One for pc communication and other for xbee radios. I attached my code, if you want to look at it. 

    I've just tried to add uartstdio.c and .h into my code. 

    Then, I clicked in Add files and I chose Link filles to my project directory. 

    It compiles, but during debugging, there is an error saying  No source available for "SysCtlDelay() at C:/Users\Onofre\workspace_v6_1\MiniStation\Debug\MiniStation.out:{3} 0x1000{4}" 

     

    Thanks!

    Thiago

    This is my code

    #include <stdint.h>

    #include <stdbool.h>

    #include "inc/hw_ints.h"

    #include "inc/hw_memmap.h"

    #include "inc/hw_types.h"

    #include "driverlib/gpio.h"

    #include "driverlib/interrupt.h"

    #include "driverlib/pin_map.h"

    #include "driverlib/sysctl.h"

    #include "driverlib/uart.h"

    #include "driverlib/timer.h"

    #include "utils/uartstdio.h"

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

    //

    // Number of interrupts before the timer gets turned off.

    //

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

    #define NUMBER_OF_INTS          1000

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

    //

    // Counter to count the number of interrupts that have been called.

    //

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

    static volatile uint32_t g_ui32Counter = 0;

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

    // Uart0 Interrupt Handler - Connected to PC - Pins A0 A1

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

    void UART0IntHandler(void)

    {

        uint32_t ui32Status;

        ui32Status = UARTIntStatus(UART0_BASE, true); //get interrupt status

        UARTIntClear(UART0_BASE, ui32Status); //clear the asserted interrupts

        while(UARTCharsAvail(UART0_BASE)) //loop while there are chars

        {

            //UARTCharPutNonBlocking(UART0_BASE, UARTCharGetNonBlocking(UART0_BASE)); //echo character

            GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2); //blink LED

            SysCtlDelay(SysCtlClockGet() / (1000 * 3)); //delay ~1 msec

            GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0); //turn off LED

        }

    }

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

    // Uart1 Interrupt Handler - Connected to the Xbee Radio - Pins B0 B1

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

    void UART1IntHandler(void)

    {

        uint32_t ui32Status;

        ui32Status = UARTIntStatus(UART1_BASE, true); //get interrupt status

        UARTIntClear(UART1_BASE, ui32Status); //clear the asserted interrupts

        while(UARTCharsAvail(UART1_BASE)) //loop while there are chars

        {

            //UARTCharPutNonBlocking(UART1_BASE, UARTCharGetNonBlocking(UART1_BASE)); //echo character

            GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_PIN_1); //blink LED

            SysCtlDelay(SysCtlClockGet() / (1000 * 3)); //delay ~1 msec

            GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1, 0); //turn off LED

        }

    }

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

    //

    // The interrupt handler for the Timer0B interrupt.

    //

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

    void

    Timer0BIntHandler(void)

    {

        //

        // Clear the timer interrupt flag.

        //

        TimerIntClear(TIMER0_BASE, TIMER_TIMB_TIMEOUT);

        //

        // Update the periodic interrupt counter.

        //

        g_ui32Counter++;

        //

        // Once NUMBER_OF_INTS interrupts have been received, turn off the

        // TIMER0B interrupt.

        //

        if(g_ui32Counter == NUMBER_OF_INTS)

        {

            //

            // Disable the Timer0B interrupt.

            //

            IntDisable(INT_TIMER0B);

            //

            // Turn off Timer0B interrupt.

            //

            TimerIntDisable(TIMER0_BASE, TIMER_TIMB_TIMEOUT);

            //

            // Clear any pending interrupt flag.

            //

            TimerIntClear(TIMER0_BASE, TIMER_TIMB_TIMEOUT);

        }

    }

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

    // Configure the UART0 and its pins.

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

    void ConfigureUART0(void)

    {

        //

        // Enable the GPIO Peripheral used by the UART.

        //

        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

        //

        // Enable UART0

        //

        SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

        //

        // Configure GPIO Pins for UART mode.

        //

        GPIOPinConfigure(GPIO_PA0_U0RX);

        GPIOPinConfigure(GPIO_PA1_U0TX);

        GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

        //

        // Use the internal 16MHz oscillator as the UART clock source.

        // Initialize the UART for console I/O.

        //

        //UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));

        // Use the internal 16MHz oscillator as the UART clock source.

        //

        UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);

        IntMasterEnable(); //enable processor interrupts

        IntEnable(INT_UART0); //enable the UART interrupt

        //UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT); //only enable RX and TX interrupts

        //

        // Initialize the UART for console I/O.

        //

        UARTStdioConfig(0, 115200, 16000000);

    }

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

    // Configure the UART1 and pins PB0 - PB1

    // This UART1 is used for the XBee Radio

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

    void ConfigureUART1(void)

    {

        //

        // Enable the GPIO Peripheral used by the UART1.

        //

        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

        //

        // Enable UART1

        //

        SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);

        //

        // Configure GPIO Pins for UART1 mode.

        //

        GPIOPinConfigure(GPIO_PB0_U1RX);

        GPIOPinConfigure(GPIO_PB1_U1TX);

        GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);

        //

        // Use the internal 16MHz oscillator as the UART clock source.

        // Initialize the UART for console I/O.

        //

        UARTConfigSetExpClk(UART1_BASE, SysCtlClockGet(), 115200,

            (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));

        IntMasterEnable(); //enable processor interrupts

        IntEnable(INT_UART1); //enable the UART interrupt

        UARTIntEnable(UART1_BASE, UART_INT_RX | UART_INT_RT); //only enable RX and TX interrupts

    }

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

    //

    // Configure Timer0B as a 16-bit periodic counter with an interrupt

    // every 1ms.

    //

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

    /*

    void ConfigureTimer0B(void)

    {

    //

        // The Timer0 peripheral must be enabled for use.

        //

        SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);

        //

        // Configure Timer0B as a 16-bit periodic timer.

        //

        TimerConfigure(TIMER0_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_B_PERIODIC);

        //

        // Set the Timer0B load value to 1ms.

        //

        TimerLoadSet(TIMER0_BASE, TIMER_B, SysCtlClockGet() / 1000);

        //

        // Enable processor interrupts.

        //

        IntMasterEnable();

        //

        // Configure the Timer0B interrupt for timer timeout.

        //

        TimerIntEnable(TIMER0_BASE, TIMER_TIMB_TIMEOUT);

        //

        // Enable the Timer0B interrupt on the processor (NVIC).

        //

        IntEnable(INT_TIMER0B);

        //

        // Initialize the interrupt counter.

        //

        g_ui32Counter = 0;

        //

        // Enable Timer0B.

        //

        TimerEnable(TIMER0_BASE, TIMER_B);

    }*/

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

    // Configure PORTF Leds//

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

    void ConfigureBuiltInLeds(void)

    {

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); //enable GPIO port for LED

        GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2|GPIO_PIN_1); //enable pin for LED PF2

    }

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

    // Configure system clock

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

    void ConfigureSytem(void)

    {

    SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);

    }

    int main(void) {

    //uint32_t ui32PrevCount = 0;

    ConfigureSytem();

    ConfigureBuiltInLeds();

    ConfigureUART0();

    ConfigureUART1();

     UARTprintf("uart working");

    }

    No source available for "SysCtlDelay() at C:/Users\Onofre\workspace_v6_1\MiniStation\Debug\MiniStation.out:{3} 0x1000{4}" 

  • I've just figure out how to do it.
    utils/uartstdio is not compiled, as JustGreg replied.
    Then, the problem was: how to add this file in my project.

    These are the steps:
    Click in: project>> New>>Folder
    Select the folder name. I did Utils, for example.
    Click in Advanced and select Use default location

    Left click on the new folder
    New>> File
    Click in Advanced
    Select: "Link to file in the file system"
    Click in Browse...
    Find the Utils/uartstdio.c

    It is done!
    Compile, and the uartprintf works!