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.
Tool/software: TI C/C++ Compiler
I am using the sprintf function in a C++ class function to format a string of text and when I try and use the %f formatting for a float, long double or anything the processor hangs in the sprintf routine or generates garbage for text. The %g format seems to work OK, but it has limited formatting. I am using CCS 7.4.0.00015.
Thanks
Make sure you #include <stdio.h> . Be certain the stack and heap are big enough. Further details are in the article Tips For Using printf.
Thanks and regards,
-George
We cannot advance this issue without a test case. Please submit one as described in the article How to Submit a Compiler Test Case.
Thanks and regards,
-George
Hi George,
Sorry for the delay. I took the adc_soc_continuous_cpu01 demo and put in two sprintf() calls. the first uses %g and the second uses %f. the %g works and the %f hangs forever. This happens whether the source is C or C++.
Thanks!
**** Build of configuration CPU1_RAM for project adc_soc_continuous_cpu01 **** "C:\\ti\\ccsv7\\utils\\bin\\gmake" -k all 'Building file: "C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/source/F2837xD_Adc.c"' 'Invoking: C2000 Compiler' "C:/ti/ccsv7/tools/compiler/ti-cgt-c2000_16.9.6.LTS/bin/cl2000" -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 --include_path="C:/ti/ccsv7/tools/compiler/ti-cgt-c2000_16.9.6.LTS/include" --include_path="C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/headers/include" --include_path="C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/include" --define=CPU1 -g --diag_suppress=1311 --diag_warning=225 --display_error_number --preproc_with_compile --preproc_dependency="F2837xD_Adc.d_raw" "C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/source/F2837xD_Adc.c" 'Finished building: "C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/source/F2837xD_Adc.c"' 'Building file: "C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/source/F2837xD_CodeStartBranch.asm"' 'Invoking: C2000 Compiler' "C:/ti/ccsv7/tools/compiler/ti-cgt-c2000_16.9.6.LTS/bin/cl2000" -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 --include_path="C:/ti/ccsv7/tools/compiler/ti-cgt-c2000_16.9.6.LTS/include" --include_path="C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/headers/include" --include_path="C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/include" --define=CPU1 -g --diag_suppress=1311 --diag_warning=225 --display_error_number --preproc_with_compile --preproc_dependency="F2837xD_CodeStartBranch.d_raw" "C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/source/F2837xD_CodeStartBranch.asm" 'Finished building: "C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/source/F2837xD_CodeStartBranch.asm"' 'Building file: "C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/source/F2837xD_DefaultISR.c"' 'Invoking: C2000 Compiler' "C:/ti/ccsv7/tools/compiler/ti-cgt-c2000_16.9.6.LTS/bin/cl2000" -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 --include_path="C:/ti/ccsv7/tools/compiler/ti-cgt-c2000_16.9.6.LTS/include" --include_path="C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/headers/include" --include_path="C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/include" --define=CPU1 -g --diag_suppress=1311 --diag_warning=225 --display_error_number --preproc_with_compile --preproc_dependency="F2837xD_DefaultISR.d_raw" "C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/source/F2837xD_DefaultISR.c" 'Finished building: "C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/source/F2837xD_DefaultISR.c"' 'Building file: "C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/headers/source/F2837xD_GlobalVariableDefs.c"' 'Invoking: C2000 Compiler' "C:/ti/ccsv7/tools/compiler/ti-cgt-c2000_16.9.6.LTS/bin/cl2000" -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 --include_path="C:/ti/ccsv7/tools/compiler/ti-cgt-c2000_16.9.6.LTS/include" --include_path="C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/headers/include" --include_path="C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/include" --define=CPU1 -g --diag_suppress=1311 --diag_warning=225 --display_error_number --preproc_with_compile --preproc_dependency="F2837xD_GlobalVariableDefs.d_raw" "C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/headers/source/F2837xD_GlobalVariableDefs.c" 'Finished building: "C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/headers/source/F2837xD_GlobalVariableDefs.c"' 'Building file: "C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/source/F2837xD_Gpio.c"' 'Invoking: C2000 Compiler' "C:/ti/ccsv7/tools/compiler/ti-cgt-c2000_16.9.6.LTS/bin/cl2000" -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 --include_path="C:/ti/ccsv7/tools/compiler/ti-cgt-c2000_16.9.6.LTS/include" --include_path="C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/headers/include" --include_path="C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/include" --define=CPU1 -g --diag_suppress=1311 --diag_warning=225 --display_error_number --preproc_with_compile --preproc_dependency="F2837xD_Gpio.d_raw" "C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/source/F2837xD_Gpio.c" 'Finished building: "C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/source/F2837xD_Gpio.c"' 'Building file: "C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/source/F2837xD_Ipc.c"' 'Invoking: C2000 Compiler' "C:/ti/ccsv7/tools/compiler/ti-cgt-c2000_16.9.6.LTS/bin/cl2000" -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 --include_path="C:/ti/ccsv7/tools/compiler/ti-cgt-c2000_16.9.6.LTS/include" --include_path="C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/headers/include" --include_path="C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/include" --define=CPU1 -g --diag_suppress=1311 --diag_warning=225 --display_error_number --preproc_with_compile --preproc_dependency="F2837xD_Ipc.d_raw" "C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/source/F2837xD_Ipc.c" 'Finished building: "C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/source/F2837xD_Ipc.c"' 'Building file: "C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/source/F2837xD_PieCtrl.c"' 'Invoking: C2000 Compiler' "C:/ti/ccsv7/tools/compiler/ti-cgt-c2000_16.9.6.LTS/bin/cl2000" -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 --include_path="C:/ti/ccsv7/tools/compiler/ti-cgt-c2000_16.9.6.LTS/include" --include_path="C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/headers/include" --include_path="C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/include" --define=CPU1 -g --diag_suppress=1311 --diag_warning=225 --display_error_number --preproc_with_compile --preproc_dependency="F2837xD_PieCtrl.d_raw" "C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/source/F2837xD_PieCtrl.c" 'Finished building: "C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/source/F2837xD_PieCtrl.c"' 'Building file: "C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/source/F2837xD_PieVect.c"' 'Invoking: C2000 Compiler' "C:/ti/ccsv7/tools/compiler/ti-cgt-c2000_16.9.6.LTS/bin/cl2000" -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 --include_path="C:/ti/ccsv7/tools/compiler/ti-cgt-c2000_16.9.6.LTS/include" --include_path="C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/headers/include" --include_path="C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/include" --define=CPU1 -g --diag_suppress=1311 --diag_warning=225 --display_error_number --preproc_with_compile --preproc_dependency="F2837xD_PieVect.d_raw" "C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/source/F2837xD_PieVect.c" 'Finished building: "C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/source/F2837xD_PieVect.c"' 'Building file: "C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/source/F2837xD_SysCtrl.c"' 'Invoking: C2000 Compiler' "C:/ti/ccsv7/tools/compiler/ti-cgt-c2000_16.9.6.LTS/bin/cl2000" -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 --include_path="C:/ti/ccsv7/tools/compiler/ti-cgt-c2000_16.9.6.LTS/include" --include_path="C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/headers/include" --include_path="C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/include" --define=CPU1 -g --diag_suppress=1311 --diag_warning=225 --display_error_number --preproc_with_compile --preproc_dependency="F2837xD_SysCtrl.d_raw" "C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/source/F2837xD_SysCtrl.c" "C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/source/F2837xD_SysCtrl.c", line 828 (col. 47): advice #2614-D: (Performance) Use --fp_mode=relaxed to enable TMU hardware support for FP division. 'Finished building: "C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/source/F2837xD_SysCtrl.c"' 'Building file: "C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/source/F2837xD_usDelay.asm"' 'Invoking: C2000 Compiler' "C:/ti/ccsv7/tools/compiler/ti-cgt-c2000_16.9.6.LTS/bin/cl2000" -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 --include_path="C:/ti/ccsv7/tools/compiler/ti-cgt-c2000_16.9.6.LTS/include" --include_path="C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/headers/include" --include_path="C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/include" --define=CPU1 -g --diag_suppress=1311 --diag_warning=225 --display_error_number --preproc_with_compile --preproc_dependency="F2837xD_usDelay.d_raw" "C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/source/F2837xD_usDelay.asm" 'Finished building: "C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/source/F2837xD_usDelay.asm"' 'Building target: "adc_soc_continuous_cpu01.out"' 'Invoking: C2000 Linker' "C:/ti/ccsv7/tools/compiler/ti-cgt-c2000_16.9.6.LTS/bin/cl2000" -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 --define=CPU1 -g --diag_suppress=1311 --diag_warning=225 --display_error_number -z -m"adc_soc_continuous_cpu01.map" --stack_size=0x100 --warn_sections -i"C:/ti/ccsv7/tools/compiler/ti-cgt-c2000_16.9.6.LTS/lib" -i"C:/ti/ccsv7/tools/compiler/ti-cgt-c2000_16.9.6.LTS/include" -i"C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/common/cmd" -i"C:/ti/C2000Ware_1_00_03_00_Software/device_support/f2837xd/headers/cmd" --reread_libs --display_error_number --xml_link_info="adc_soc_continuous_cpu01_linkInfo.xml" --rom_model -o "adc_soc_continuous_cpu01.out" "./F2837xD_Adc.obj" "./F2837xD_CodeStartBranch.obj" "./F2837xD_DefaultISR.obj" "./F2837xD_GlobalVariableDefs.obj" "./F2837xD_Gpio.obj" "./F2837xD_Ipc.obj" "./F2837xD_PieCtrl.obj" "./F2837xD_PieVect.obj" "./F2837xD_SysCtrl.obj" "./F2837xD_usDelay.obj" "./adc_soc_continuous_cpu01.obj" "../2837xD_RAM_lnk_cpu1.cmd" -lrts2800_fpu32.lib -lF2837xD_Headers_nonBIOS_cpu1.cmd -llibc.a <Linking> 'Finished building target: "adc_soc_continuous_cpu01.out"' **** Build Finished ****
******************************************************************************
TMS320C2000 Linker PC v16.9.6
******************************************************************************
>> Linked Mon Mar 19 14:17:19 2018
John Churchill said:I increased the stack size to 0x400
That's not enough. I created a small program that calls sprintf and used call_graph from the cg_xml package to determine how much stack is required. It says 0x49e words of stack are used. To be safe, you should allocate more than that.
John Churchill said:I am not sure why the %g format would work and the %f doesn't
Given what we know now, it is harder to explain why %g works than it is to explain why %f fails.
Thanks and regards,
-George