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.

Compiler/TMS320F28388D: Can't get sprintf to work with floats

Part Number: TMS320F28388D
Other Parts Discussed in Thread: C2000WARE

Tool/software: TI C/C++ Compiler

I am having issues with sprintf  (program hangs with floating point) and I've noted that this topic has been brought up numerous times but I can't seem to find a solid solution.  Is this related to the compiler, linker or both?  I am just working with one of the example programs currently.

Linker flags:

-v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --idiv_support=idiv0 --tmu_support=tmu0 -Ooff --define=DEBUG --define=CPU1 --define=printf_support=full --diag_suppress=10063 --diag_warning=225 --diag_wrap=off --display_error_number --gen_func_subsections=on --abi=eabi -z -m"sci_ex3_echoback.map" --heap_size=0x200 --stack_size=0x100 --warn_sections -i"C:/ti/ccs910/ccs/tools/compiler/ti-cgt-c2000_18.12.2.LTS/lib" -i"C:/ti/ccs910/ccs/tools/compiler/ti-cgt-c2000_18.12.2.LTS/include" --reread_libs --define=RAM --diag_wrap=off --display_error_number --xml_link_info="sci_ex3_echoback_linkInfo.xml" --entry_point=code_start --rom_model

Compiler flags:

-v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --idiv_support=idiv0 --tmu_support=tmu0 -Ooff --include_path="C:/Users/Bob/workspace_v9/sci_ex3_echoback" --include_path="C:/Users/Bob/workspace_v9/sci_ex3_echoback/device" --include_path="C:/ti/ccs910/C2000Ware_2_00_00_03_Software/driverlib/f2838x/driverlib" --include_path="C:/ti/ccs910/ccs/tools/compiler/ti-cgt-c2000_18.12.2.LTS/include" --define=DEBUG --define=CPU1 --define=printf_support=full --diag_suppress=10063 --diag_warning=225 --diag_wrap=off --display_error_number --gen_func_subsections=on --abi=eabi

  • Hi,

    stack size is clearly to small for FP printf. Minimum was >0x300 last time I checked it.

    On other architectures to check stack size requirements usually you fill stack area with some known pattern, call routine and look for changes in stack area. This method is not good fit for C2000 printf. C2000 printf routines have several big buffers on stack, so you may miss real requirement due to memory holes in printf stack frame. Since stack requires its own RAM segment and you can't easily switch stack to big memory segment, I suggest you to notice stack pointer before print call then start stepping into deepest printf subroutine and notice the biggest SP value. Difference of worst case SP with initial SP will give you idea about minimum stack size.

  • The reply by EK is correct, except for one thing.  Performing sprintf of a floating number requires 0x400 words of stack, not just 0x300.

    Did you change the linker --stack_size option?  Is it working now?

    Thanks and regards,

    -George

  • I did increase the stack to 300 and then to 400.  No luck.  I'll be the first to admit that it is likely something simple but I just don't know what that is.

    I am just running one of the example programs so I know I can't be to far off base here.  Intergers are working as expected....

    Bob

  • Make sure you #include <stdio.h>

    If that doesn't work, skim through the suggestions in http://software-dl.ti.com/ccs/esd/documents/sdto_cgt_tips_for_using_printf.html .  Most of those are for problems with trying to get the output to show up on the Console view in CCS.  That is, they apply to printf but not sprintf.  But maybe I overlooked something.

    Thanks and regards,

    -George

  • George,

    I do have #include stdio.h.   I'll take a look at the link that you provided, maybe there is a hint in there somewhere.

    Bob

  • FYI, I found that if I bump my stack size to 0x0800 then everything works fine.  At 0x0400 it did not work.  At some point I'll go back and figure out if where the 'cutoff' is but for now I'm content.

    Thanks to those of you that pointed me in the right direction.