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.

What is the right way to use TIVA C examples?

Hey :-)

I am relatively new in TIVA C 1294NCPDT Cortex M4 world :-)

I intend to use the attached examples in TIVA C software. For example I tried to use master_slave_loopback.c as an example:

I built a new project, set up the microcontroller type and includes directory, attached driverlib.lib file, and then pasted the code of master_slave_loopback.c in my main.c file.

but when I try to compile the code, I always get some errors. I tried to solve that for more that 10 hours but no results !!

Could anybody tell me please the right way to use the mentioned example (and by that I can use the using method with other examples files)

cuz I want to keep going in learning but this problem blocked my way!!!

Thank's in advance.

  • Hi,

       Welcome to E2E. See, some sticky posts in this forum for some guidelines.

    Mohammed Noureldin said:

    I built a new project, set up the microcontroller type and includes directory, attached driverlib.lib file, and then pasted the code of master_slave_loopback.c in my main.c file.

    but when I try to compile the code, I always get some errors. I tried to solve that for more that 10 hours but no results !

          Post the compilation errors here.

          These peripheral examples are sometimes need to be modified to make it to work. There are instructions at the code comments about what to modify. But, to be sure, verify if the peripherals you are using at master_slave_lookback.c , if it does exist at your Tiva microcontroller. You, can verify that at the datasheet.

           Also, if you are using CCS and you are new to using it, I would advice you to go through the laboratory exercise for it. Download the workbook pdf at the link below. You, can learn from that.

    http://processors.wiki.ti.com/index.php/Creating_IoT_Solutions_with_the_TM4C1294XL_Connected_LaunchPad_Workshop?keyMatch=tiva%20connected%20launchpad%20workshop&tisearch=Search-EN

    - kel

  • Thank you for your replay,

    Actually there is nothing to be edited by me, and I have already gone through the lab, the lab projects worked fine with me! but when I intend to build up my new own project, problems raise up!

    here is the errors:

    <Linking>
    
     undefined       first referenced
    
      symbol             in file     
    >> Compilation failure
     ---------       ----------------
     UARTStdioConfig ./main.obj      
     UARTprintf      ./main.obj      
    
    error #10234-D: unresolved symbols remain
    error #10010: errors encountered during linking; "lab08.out" not built
    gmake: *** [lab08.out] Error 1
    gmake: Target `all' not remade because of errors.
    

    taking in consederation I have attached all required libraries (they have been already attached by the example, I didn't edit anything there):

    #include <stdbool.h>
    #include <stdint.h>
    
    #include "inc/hw_memmap.h"
    
    #include "driverlib/gpio.h"
    
    #include "driverlib/sysctl.h"
    
    #include "inc/hw_types.h"
    
    #include "driverlib/uart.h"
    #include "utils/uartstdio.h"
    #include "inc/hw_i2c.h"
    #include "driverlib/i2c.h"
    
    #include "driverlib/pin_map.h"

  • Hi, 

        The laboratory examples are okay. I have tried most of these labs without problems. You are encountering that error at lab8 because you did something wrong.

    Mohammed Noureldin said:
    undefined first referenced symbol in file

         You, have this error because you have two symbols or two C objects that have been defined twice. Meaning possible there are two or more files with that same C object definitions. This is an error related to C One Definition Rule.

         Possible that you used the same folder at your previous laboratory exercise for this laboratory 8, that cause this problem.

         I suggest you go back to laboratory exercise 1-2-3. You, can learn from that again the steps how to set-up your CCS and make a new CCS project.

    - kel

  • Actually this error is not with lab8, lab 8 is compiled properly!

    this problem occurs when I try to build a new project and copy

    C:\ti\TivaWare_C_Series-2.1.0.12573\examples\peripherals\i2c\master_slave_loopback.c

    example file into my main.c file in my own project.

    because of that I am asking you please to give me the right way to use this c file which has been attached to tiva ware files as a (C file) and not a (project).

    Cuz I always have trouble when I try to use such files which include UART lines!!!

    and thank's a lot  :-)

  • Hi Mohammed,

    You still have that error "undefined first reference" error to solve.

    One way, is to use existing examples and just append the master_slave_loopback.c code. You, can use the "hello" example program as base. If you check the project view uartsdio is already included at the hello example program.

    Mohammed Noureldin said:
    >> Compilation failure --------- ---------------- UARTStdioConfig ./main.obj UARTprintf ./main.obj

    As you can see at master_slave_loopback.c code uses UARTStdioConfig and UARTprintf. You are encountering these errors possible that you did not include uartstdio.c at the libraries of your new project.

    What IDE are you using?

    - kel

  • Hey!

    Mohammed Noureldin said:
    problem occurs when I try to build a new project

    This most always happens when users (especially new ones) attempt to, "build their own project!"  And - as in your case too - never is any justification given for the "need" for "own" project!   Thus - a mistaken/poorly considered desire derails/frustrates...  (hundreds - perhaps thousands - you are far, far from alone)

    Solution - Hey - use the closest, "existing project!"  Not your, "own!"  Existing projects have been built, test/verified by experts - those w/far more knowledge than you/me - it makes little sense for you to "cast off" from such safe harbor.  (and - did I say - such "own project" desire is never/ever explained/justified!)  (perhaps to "hide" that help/aid from the boss?)

    Hooking into a "known-good" existing project will remedy (likely eliminate) most all (often all) of the errors which have plagued your development efforts.  You may then - cut/paste from example code - with a much greater probability of success.  And - you may gradually/systematically, "comment out" aspects of the original project - foreign to your specific needs.  End result likely will be a, "working project" - with your "brand" - and little of the pain/agony caused by the unforgiving demands of IDE mastery/set-up/hooks...  (is your goal MCU skill or IDE? - we choose MCU!)

    As other has noted - sometimes example code fails to fully set-up/config the targeted peripheral.  That then - becomes your job and Peripheral Driver Library Guide and review of the driver lib source code will expand your usage & understanding - those details...

  • I am using CCS.

    I think you are right, I have deleted the project, but I really didn't add uartstdio.c file.

    But could you please tell me when I have to add c files? I thought that it is sufficient when I incudes *.h files.

    I will go through hello example and tell you what ever new I get.

    Thank you :)

  • Appears our posts have just, "crossed."  Another viewpoint/suggestion appears @ 18:32 timestamp - this (your) thread.

  • Hey CB1 :-)

    I intend to do that, and actually that is what I am doing right now (trying to get some data from uart in hello examples) but I haven't received any data till now :-D, at least I know that compilation and programming worked successfully. Now trying to see some "hello world" on the terminal :-D

    Thank you for your reply :-)

  • Good for you, Mohammed.  (but do "kill" the Hey - it's too aggressive/kid-like)  (I know you're kidding - but enough)

    Insure that you properly "match" each/every communication setting - both your MCU and PC Com program.  Those include - but may not be limited to: baud rate (I'd start @ 9600 - easier to manage @ both ends), number of data and stop bits, parity (none) and insure @ PC side that, "NO HW blocks/handshakes" are selected.

    Also - any remote which operates at RS232 signal levels can (WILL) damage your unprotected MCU inputs!  Unless you've a proper USB to Serial (CMOS) level shifter you will require an RS232 level shifter when attaching your UART pins to a remote operating @ RS232 levels.

    And - double check your cable/wiring - so easy to cross TX w/ RX - communication is "hard" when that happens...

  • Sorry, I just see people use "Hey" instead of "Hi", :-) so let's say hi ;-)

    Now it works, I used Putty as a terminal and it worked well! the problem was (as I think) in CCS Terminal, I couldn't see any data, though I sat up baud rate and other parameters.

    Now I can go deeply in it and try to copy and paste some lines from other examples into hello example.

    again, thank you for your reply :-)

  • That's great - credit is all yours - you listened - focused and success was yours!

    Suggest that you stay w/reasonably small, simple examples in this beginning period.  Build your understanding, confidence via this natural (unrushed) method.

    And do read/review - keep always open - the PDL.  It will save you countless time/effort. 

    Bon chance, mon ami...