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/MSP430FR5994: Printf to UART (putty) missing %d, %x, %f, etc. but works on Console

Part Number: MSP430FR5994

Tool/software: Code Composer Studio

I want to output to a serial program such as hyperterm and not the console. So I follow the Wiki link at https://processors.wiki.ti.com/index.php/Printf_support_for_MSP430_CCSTUDIO_compiler

I then use the following: int16_t fputc(int16_t my_char, register FILE *_fp) as shown in the Wiki. Not to drop back a moment, this all works fine when using IAR and the function int16_t putchar(int16_t c)

The problem is when output data goes to the serial program (putty), it is missing all the %d, %x, %f, etc. and I do have the Level of printf/scanf set to FULL in Language Options.

Outputs

Version: ..

should output 

Version: 3.0.7

Notice its missing the 3, 0. 7 in this case the %d.

All the output displays fine on the Console.

Has anyone seen this problem?

Thanks,

-Jim

  • Sorry if this is unclear, but fputc() does not do any formatting, it just outputs a single character. You need to use fprintf(). If you are using fprintf() your code did not show up. %d should absolutely work.

    If you are using fprintf(f, "%d", 3.0.7) that won't work because it will think the 3.0.7 is floating point.

  • Hi Keith,

    Thanks for responding. Here's my issue. I've been using IAR and using the int16_t putchar(int16_t c) to output to a hyperterm type serial program called putty.  I've been using the printf with no issues on IAR.

    Now I'm trying to rehost the code to Code Composer Studio and am having a really hard time overcoming outputting via the UART A0 to the serial program. If I use the putchar(int16_t c) call, I get the following error in CCS:

    error #10056: symbol "putchar" redefined: first defined in "./source/queue.obj"; redefined in "C:\ti\ccs1000\ccs\tools\compiler\ti-cgt-msp430_20.2.1.LTS\lib\rts430x_lc_ld_eabi.lib<fputc.c.obj>"

    If i comment the putchar call out, I see the output goes to CCS Console. So I saw a post somewhere here and saw a Wik.ti post on how to make it go to the serial port and not the CCS Console. Please look at the bottom portion of the link for wiki I posted above.

    The wiki article say to use the int16_t fputc(int16_t c, register FILE *_fp). But when I do, I lose the printf formating of %d, %ld, %x, %f, etc...

    If I use the fprintf, it doesn't do anything.

    Any insight to this appreciated.

    Thanks,

    -Jim

  • Got it to work. I was only using the fputc function in my code. Once I added the fputs function in, all worked fine. Just like the wiki link explained. That was really annoying when you're so close to solving something and things just don't want to cooperate.

    My head scratching thing is; why did it need the string fputs. I'm only putting out %d, %x, %f, etc.??

    Maybe a TI expert that knows the libraries can explain. Do I need the fgetc to receive data? I'm assuming so.

    BEFORE:

    Activity Threshold: 0x
    Activity Time: 0x
    InActivity Threshold: 0x
    InActivity Timeout: sec
    Activity Controls: 0x
    Filter Controls: 0x
    Power Controls: 0x

    AFTER:

    Activity Threshold: 0x64
    Activity Time: 0x3
    InActivity Threshold: 0x64
    InActivity Timeout: 60 sec
    Activity Controls: 0x3F
    Filter Controls: 0x0
    Power Controls: 0x2

    -JIm

  • Jim Patten2 said:
    why did it need the string fputs.

    I don't know.  I am unable to reproduce the problem.  

    Is your program organized as a project in Code Composer Studio?  If so, please follow the directions in the article Sharing projects to zip up the project, then attach that zip file to your next post.

    Thanks and regards,

    -George

  • It is probably more efficient to use fputs() rather than fputc() when implementing fprintf(). Being a lazy programmer, I know which I would choose. 8^)