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.

CCS/TM4C123GH6PZ: Using the UARTPrintf function

Part Number: TM4C123GH6PZ

Tool/software: Code Composer Studio

Hello,

I want to use the "UARTprintf" function in my code instead of "UARTputchar"

For that purpose - I include the following:

#include "driverlib/uart.h"
#include "utils/uartstdio.h"

I compiled my code and I get the following error:

Description Resource Path Location Type
unresolved symbol UARTprintf, first referenced in ./main.obj PID C/C++ Problem

What did I miss ?

  • Hello Shai,

    Those should be the only includes you need to add in. Can you try cleaning your project and re-building after the clean?
  • Hi,

    I right clicked on the project name in the workspace and then "Clean Project"
    I then rebuilt the project.

    The problem persists.
  • Hello Shai,

    Okay did a little playing around with examples and the missing step you need to do is to Link the uartstdio.c file to your CCS project.

    This can be done by going to the TivaWare utils folder and drag & dropping uartstdio.c into your CCS project. It will ask you if you want to Copy or Link the file. Select Link. I would also recommend that you Link it relative to SW_ROOT.

    If you have done this correctly, in the CCS Project Properties under Resource -> Linked Resources in the "Linked Resources" tab, you will see this:

  • This did solve the problem.

    But I don't get this at all.

    But why was this necessary ?

    In my main.c I used:

    #include "utils/uartstdio.h"

    And utils/uartstdio.c is part of TivaWare.

    As you can see in the attached snapshot TivaWare is added to the search path.

    What am I missing ??

  • Hello Shai,

    The include for TivaWare is there, yes, but the CCS project did not see the exact .c file where the function is until it was linked. I was under the same impression as you when I looked at your post this weekend until I came into work today and gave it more thought. That is when I went in to compare project differences and confirmed the Linking was different. So there is a big difference between Included and Linked.

    You'll see that for projects with multiple files from folders outside of driverlib, there are Links made for each file.

    I think Include tells the compiler where to look to find the headers which determine what functions are called, but Link is needed to actually add a .c file so it can be compiled within the project and without the link the .h file sees the file but cannot make CCS compile that .c file which causes the error.

    If you want to know for sure, you should ask the CCS experts on their forum though, I could be missing a key detail or two... I only know the tool enough to be dangerous with it.
  • I see your point - but in such a case:
    Why the problem occurs only with UARTprint and not all the other functions I used from TivaWare ?

    I'll do as suggested and post on the CCS forum.
    Thanks a lot Ralph!
    You're dangerous in a good way...
  • Hello Shai,

    Other functions from TivaWare come from Driverlib which is included as a full library with the include for driverlib.lib and that means all APIs are accessible with only the proper include statements for header files. No need to add individual .c files to the project as a result since they are already compiled within the .lib.