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.

Cannot printf floats

Other Parts Discussed in Thread: TMS570LS3137

Hello,

I am having trouble printing float values to the console.

The following code demonstrates this:

void main(void)
{


    printf("Hello World!\n");
    printf( "One int %i\n", 10);
    printf( "Two ints %i, %i\n" , 10, 20);
    printf( "Two hexas %i, %x\n" , 0xabcd, 0x3a3a);
    printf( "One float %f\n", 2.5);

All is well until the pringtf statement with the %f format specifier is reached.  Then the program just hangs and the debugger is lost as to where the program counter is, so I can trace the error only as far as the call to printf with the f specifier.  Something similar happens with vsprintf, but I guess that is jusat a wrapper around printf.

I have:

floating point enabled with --float_support=VFPv3D16 and have set --printf_support=full

I can carry out floating point oprations so I assume this is correct.

I have read the note in the compiler manual (p161, section 7.2 The C I/O Functions) and set the heap to 8 * the BUFSIZ (2048 bytes) but this has no affect on my printing problem.

I have --gcc set so as to use variable arguments, apart from that all is pretty will as per the example Hello World code supplied with the USB TMS570 Devlopment Kit.

I suspect it is something trivial but  I have run out of ideas.  Any suggestions?

Thanks for any help.

Steve

 

 

 

  • Hello Steve,

    I am going to try this by myself and see whether I am having the same troubles getting an output on the console.

    By the way, which RTS library are you using? If it is not this one: rtsv7R4_A_le_v3D16_eabi.lib. Please try it out and run your program again.

    I am coming back to you as soon as possible.

    Best Regards,

    Gregor

  • Hi,

     

    thanks for looking at my problem.  I am not certain where the RTS library is specified so I cannot tell you what we are using nor can I  change it.

     

    Where abouts in the project's settings is the RTS lib found?

     

    FYI: I have floating point support (--float_support) set to VFPv3D16

    Steve

  • Have found and linked in the RTS lib you suggested:

     

    However I am now getting a linking error to do with Edianess:

     

    C:\Program Files\Texas Instruments\ccsv4\utils\gmake\gmake -k all
    'Building target: OutFile'
    'Invoking: Linker'
    "C:/Program Files/Texas Instruments/ccsv4/tools/compiler/tms470/bin/cl470" -@ccsLinker.opt -o "OutFile"
    <Linking>
    fatal error: object files have incompatible byte orderings ("C:/Program
       Files/Texas
       Instruments/ccsv4/tools/compiler/tms470/lib/rtsv7R4_A_le_v3D16_eabi.lib<copy
       _decompress_none.obj>" = little endian,
       "./FilesUnderTest/Logger/Devices/Console/Console.obj" = big endian)

    >> Compilation failure

    I have tried the CCS simulators for:

    Cortex-R4 CPU Functional Simulator, Big Endian

    Cortex-R4 CPU Functional Simulator, Big Endian (BE-8)

    Cortex-R4 CPU Functional Simulator, Little Endian

    But they all given the same error.

     

  • Steve,

    This rts library has been compiled for little endian byte ordering, as suggested in the file name. There is an equivalent rts library called rtsv7R4_A_be_v3D16_eabi.lib for the big endian byte ordering. Please use this one instead.

    Regards,

    Sunil

  • Sunil,

    thanks for your suggestion.  Am now using:

    Target: Cortex-R4 CPU Functional Simulator, Big Endian

    CCS Build: Device Endianess: big

                        Runtime Support Library: rtv7R4_A_be_v3D16_eabi.lib

    But still whan the call to printf with a %f format specifier the program halts.

    Steve

     

     

    PS

    I have rembered that I had to comment out of the sys_core the assy code that turns on the Cortex-R4F floating point unit (_coreEnableVfp_).  This looks like it ought to be used but when it is the simulator gets no further than the last line of _coreEnableVfp_ (fmxr  fpexc,   r0).  Should this piece of code be running?  If so how can I stop it locking up?

     

    Have you a CCS project that runs on the simulator (CortexR4) that prints floats to the console?  If so maybe you could send it to me and I could compare it with what I have.

     

    Steve

  • Hello Steve:

    Instead of rtv7R4_A_be_v3D16_eabi.lib use rtv7R4_T_be_v3D16_eabi.lib

    Please let me know if that fixes the problem.

    Regards,

    Enrique

  • Enrique,

     

    I have just tried you suggestion, but when this library is linked in and the program run under the debugger on the simulator the debugger does not break at the first line of main as is the case with the previouse librbary I was using.

     

    The program runs but fails to break at main, I presume it has not reached there, when I pause the debugger it is somewhere in sys memory that contains no instructions.

    Do you have a project that runs on the R4 simulator that prints floats to the console?  If so could you send me it?  If not could you create one for me please and let me examine it?

     

    Steve

     

  • Hello Steve:

    I'm using the provided "Hello World" example just adding the float printf.

    If I use rtsv7R4_A_be_v3D16_eabi.lib instead of rtsv7R4_T_be_v3D16_eabi.lib, I observe the exact same problem as you, the execution stops when trying to print the float value. I'll confirm what are the differences between those RSL's. Here are some details of my setup:

    Device Variant: TMS570LS3137

    Endianness: be32

    Code Generation Tools: TI v4.9.0

    RSL: rtsv7R4_T_be_v3D16_eabi.lib

    Target Configuration: Texas Instruments Simulator. Cortex-R4 CPU Functional Simulator, Big Endian

    Regards,

    Enrique

  • Enrique,

    I have just tried the configuration you say you use but with either of the RTS libs you state I don't get any floats printed.  Even with rtsv7R4_T_be_v3D16_eabi.lib which works for you.

    Could you please send me a copy of the project you are using?

    Steve

     

    PS Forgot to add I have upgraded to CCS v5 and compiler 4.9.1.  Whe the pringtF fails now and I pause the debugger I get this:

    No source available for "fcvt(unsigned char *, long double, int, int *, int *) at 0xb94"

  • Steve,

    I haven't checked that with CCS v5, I'll try that.

    Please send me an email to e_lizarraga@ti.com to reply with a copy of the project.

    Regards,

    Enrique

  • Enrique,

     

    is the email address you've given correct?  I keep getting:

     

    The following recipient(s) cannot be reached:

     

          e_lizarraga@ti.com on 14/11/2011 09:11

                The e-mail account does not exist at the organization this message was sent to.  Check the e-mail address, or contact the recipient directly to find out the correct address.

                < white.ext.ti.com #5.1.1 SMTP; 550 5.1.1 <e_lizarraga@ti.com>... User unknown>

     

     

    Regards,

     

    Steve

     

     

  • Hello Steve:

    I'm sorry, the correct address is e-lizarraga@ti.com.

    Regards,

    Enrique

  • Enrique,

    I have now got to the bottom of all this and the problem is solved.

    Thank you,

    Steve

  • Do you mind posting your solution?  I am running into a similar problem.  I am getting a data abort exception whenver i try to print a float.