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 linking to library in CCS 6.1

Other Parts Discussed in Thread: TM4C123GH6PM

I am adding to an already running program.

This is a TM4c123 micro controller code.

All I want to do is use:    sprintf()

I have included:

#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include <stdio.h>
#include <format.h>
#include <stdarg.h>
#include <string.h>
#include "inc/tm4c123gh6pm.h"
#include "driverlib/adc.h"

When I load the code to TM4c and run it, it runs until I reach the sprintf line of code:

sprintf(buf3, "Input Voltage = %d", ui32ADC0Value[0]);

The program hangs on this statement.

If I "step into" the above statement, CCS gives me the error message:

Can't find a source file at "/tmp/scratch/mjoyner/tools/build/arm/product/linux/lib-internal/src/sprintf.c"

(I am guessing that mjoyner is a User ... somewhere ...)

There are various libraries in the installed in the CCs heirarchy.

If I search through them, I do find the above path but I don't understand how to fix this.

I have added a path in CCS IDE in:

Projects | Properties | CCS Buld | ARM Compiler | Include Options

with the data:

C:\ti\ccsv6\ccsv6\tools\compiler\ti-cgt-arm_5.2.2\lib\src

where sprintf)_ and format() are located.

BUT, it does not work.

It's really funny ...  i have used sprintf() for 40 years .... after 1 1/2 days I have to LOL and ask for help!

Any help you can give is very much appreciated.

TIA,

Robert

  • robert palma said:
    The program hangs on this statement.

    I suspect this may be due to insufficient heap. Try increasing the heap size (and if needed, stack size) under Project Properties->Build->Linker->Basic Options.

    Some other general tips when working with C I/O routines: http://processors.wiki.ti.com/index.php/Tips_for_using_printf


    robert palma said:

    If I "step into" the above statement, CCS gives me the error message:

    Can't find a source file at "/tmp/scratch/mjoyner/tools/build/arm/product/linux/lib-internal/src/sprintf.c"

    This is expected behavior. The path it is showing is the path to that source file when the runtime library was built (the info is in the debug symbols for the library). More information is in this wiki section: http://processors.wiki.ti.com/index.php/Debug_Handbook_for_CCS#Debugging_Library_code

  • Artie,,

    Thank-you so much.   It was the Stack size.

    I had to push it up to 1000.

    Can you please help me with another simple Include question?

    I want to use itoa().

    I thought it should be in stdlib.h  ...... but I guess not since my code for itoa is not recognized.

    What Include should I use to be able to use itoa()?

    Thanks again,

    Robert

    .

  • Glad to hear that increasing stack size fixed the sprintf issue.

    robert palma said:
     I want to use itoa().

    I thought it should be in stdlib.h  ...... but I guess not since my code for itoa is not recognized.

    itoa() is not defined in the C language standards (it is an extension) and is not provided by the TI Runtime Support libraries.  

    You might be able to find itoa() function implementations on the web that you could add into your sources. Another option would be to use the ltoa() function that is included in our runtime support library.

    If you have additional questions please feel free to start a new post as the original question here has been answered.

  • Artie,

    Thanks again. I did indeed find a small portable itoa() on the Net.
    I modified it a bit and it runs well.
    Great suggestion.
    I did indeed get the sprintf() to work with your Stack size recommendation.
    Since my original need was only for an integer, I will use the itoa() instead
    since I think it might be smaller ..... these little micro-controllers have
    sooooo little RAM !
    Best to you,
    Robert