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.

Issue with printf() function in TMS570LS3137 controller using CCS 6.0.1

Other Parts Discussed in Thread: TMS570LS3137

Hi,

I want to print any message on the CCS console by loading a small program in TMS570LS3137 Controller and executing it using Emulator (Spectrum Digital XDS-220).

1. In Build settings -> ARM compiler -> Advanced options -> Library Function Assumptions, "Level of printf/scanf support required" is configured to "full"

2. In Build settings -> ARM linker -> Basic options, Heap size is configured to 0x800

3. In Debug settings -> program/memory load options, "CIO function use (requires setting a breakpoint)" option is enabled

4. In Build settings -> ARM compiler -> Include options, ""C:\ti\ccsv6\tools\compiler\arm_5.1.6\lib\src" is added in Include search path for visibility of TI library files

5. In linker command file (.cmd), .sysmem section is defined in RAM ( .sysmem : > RAM)

Code is as shown below :

#include <stdio.h>

void main()

{

printf("Hello World");

User defined code--

}


I am able to compile and load the code but unable to execute printf() function and display the message on console.

Able to step in printf() function & it is getting stuck at "__TI_file_lock(stdout);"

Please let me know how can I overcome this issue.

 

Below is the printf() function - TI library (for your reference)

_CODE_ACCESS int printf(const char *_format, ...)

{

va_list _ap;

int rval;

char *fptr = (char *)_format;

/*------------------------------------------------------------------------*/

/* The current thread in a multi-threaded application must protect access */

/* to stdout. In this case, stdout may be updated, so we must ensure that */

/* the local copy of stdout is flushed to shared memory before leaving the*/

/* critical section (invalidated if it is not modified). */

/*------------------------------------------------------------------------*/

__TI_file_lock(stdout);

/*------------------------------------------------------------------------*/

/* If the current stream is not associated with a file, return an error. */

/*------------------------------------------------------------------------*/

if (stdout->fd == -1)

{

__TI_data_synch_INV(stdout, sizeof(FILE));

__TI_file_unlock(stdout);

return (-1);

}

va_start(_ap, _format);

rval = __TI_printfi(&fptr, _ap, (void *)stdout, _outc, _outs);

va_end(_ap);

__TI_data_synch_WBINV(stdout, sizeof(FILE));

__TI_file_unlock(stdout);

return (rval);

}


Early response will be really helpful.

 

Thanks & Regards,

Satya Sudhir Sure



  • Satya Sudhir Sure,
    When I have printed to the CCS console, I have also included the following lines:
    #define Enable_CIO
    #define Enable_File_CIO

    Best regards,
    Kevin Lavery
  • In an embedded environment "Hello world" can actually be a very difficult task!  We created this wiki page to help with these types of issues since there are so many little things that can cause issues:

    http://processors.wiki.ti.com/index.php/Tips_for_using_printf

    It looks like you've addressed many of them, though I encourage you to read through the page to see if there might be other mistakes.  In particular, a couple things that come to mind:

    1. Since stdout is line buffered, you actually need a new line ('\n') to trigger something to be printed.  So instead of "Hello world!" you should try "Hello world!\n".

    2. Are you assigning the .cio section to a valid chunk of RAM in your linker command file?