TMS320F28379D: Issue Converting Float to String for SCI (UART) Transmission on C2000

Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE

Hi TI Team,

I am working with a C2000 device ([TMS320F28379D]) and using the SCI (UART) peripheral for serial communication.

Initially, I verified that SCI transmission is working correctly by sending normal strings. I was also able to convert integer values to strings and transmit them successfully.

After that, I tried to transmit floating-point values by first converting them into strings using sprintf and then sending them over SCI.

image.png

 

However, when I did this, I started observing abnormal system behavior. To isolate the issue, I then tried a simpler test by just printing the float using printf:

image.png

 

But even this did not work correctly. The output is empty, whereas the same is working fine for integer values.

From this, it seems:

  • SCI (UART) itself is working fine (verified with strings and integers)
  • The issue starts specifically when handling float values
  • Even basic float printing using printf is not working
  • Additionally, using sprintf with "%f" seems to affect system behavior

I also checked in Code Composer Studio for any option to enable float support (such as printf-related settings), but I could not find any such option.

Could you please help with:

  1. Whether float support is available in C2000?
  2. Why using sprintf with "%f" could lead to abnormal system behavior?
  3. How to correctly enable or handle float-to-string conversion in this case?
  4. Recommended method to safely transmit float values over SCI?

Thanks in advance for your support.

  • Hi Deepan,

    Yes, float support is available on C2000. To convert a float to a string, you can use the snprintf() function as you are doing. 

    To clarify, the printf() and sprintf() functions are from the standard IO library. printf() uses the stdout, which prints the string to the CCS console via the JTAG interface on the device. The SCI peripheral (UART protocol) sends messages through a separate physical connection that converts the UART protocol to USB to display to the serial terminal in CCS. These are different windows in CCS. Which are you trying to do?

    For the printf() / sprintf() functions, we have a tutorial here

    For the SCI peripheral, we have examples in the C2000ware SDK you can take a look at. Path: [C2000ware install]/driverlib/f2837xd/examples/cpu1/sci/. I would recommend trying sci_ex3_echoback. 

    Another note for this device, if using the LaunchPAD, make sure you have the _LAUNCHXL_F28379D predefined symbol defined in your project to configure the clocks properly. 

    Best Regards,

    Delaney

  • Hi,

    I am using printf to print a float value in the CCS console, and I have included the stdio.h library. The project also utilizes the UART protocol for data transmission. The SCI peripherals code is adapted from the examples in the C2000ware SDK.I have verified that the predefined symbol is correctly defined in the project; however, the issue still persists.

    Could you kindly suggest a solution or provide guidance on why printf and snprintf might not be displaying and transmitting float values correctly over UART?

    Thanks in advance for your support.

  • Hi Deepan,

    Can you show the console output you get? As I mentioned before, the printf() does not use the SCI module on the chip. It uses JTAG to print through the debugger interface.  

    Can you check your compiler setting for the --printf_support flag? This should be set to --printf_support=full to send floats. See documentation here.

    Best Regards,

    Delaney

  • Hi,

    Yes, I have already checked my compiler settings and confirmed that the --printf_support flag is set to full.


    However, I am still facing an issue where float values are not being printed in the console output. Even when I try printing a simple float value using printf, nothing appears in the console (screenshots attached).

    I am also experiencing a related issue when attempting to transmit float values as strings over UART (using snprintf). I have attached screenshots of the console output for both issues in my previous message.

    Could you kindly suggest what else I should check or try to resolve this issue?

    Thank you in advance for your support.

  • Hi Deepan,

    Apologies for the delay. A couple other things to try:

    • Can you check your map file to see which library is being used for the printf calls?
    • Can you try building your project with no optimization? High optimization levels may remove or inline the printf calls.

    Best Regards,

    Delaney 

  • Hi,

    Apologies for the delayed response.

    The library currently being used for the printf calls is rts2800_fpu32_eabi.lib. And I also attempted to build the project with optimization disabled, but the issue persists—float values are still not being printed correctly.


    Could you please suggest what I can try next to resolve this issue?

    Thank you in advance for your support.

  • Hi Deepan,

    Let me get back to you on this next week.

    Best Regards,

    Delaney

  • Hi Deepan,

    Just to update, I still haven't had a chance to look into this more for you. I am aiming to have a response early next week. Apologies for the delay.

    Best regards,

    Delaney

  • Hi Deepan,

    Just to update, I still haven't had time to look into this but will update when I do.

    Best Regards,

    Delaney

  • Hi TI Team,

    Thank you for the update. We understand there has been limited time to look into this; however, we would appreciate any opportunity to progress this further as we are awaiting a solution. Looking forward to your update.

    Thank you in advance for your support.

    Regards, 
    Deepan V.

  • Hi Deepan,

    Understood, I will try to find time to look into this tomorrow. Thank you for your patience.

    Best Regards,

    Delaney

  • Hi Deepan,

    Apologies again for the delay. I was able to get printf() and snprintf() working with a float on my setup. I had to increase both my stack size and heap size quite a bit, current values are below:

    This also required some modifications to the linker cmd file to allocate more memory to the sections where the heap and stack are placed. Below is my code, please try this on your setup and let me know if you run into any issues. 

            char temparray[16];
            float value = 3.14159265f;
            int length = snprintf(temparray, sizeof(temparray), " %.04f", value);
            printf("PIE VALUE: %f\n", value);

    Best Regards,

    Delaney

  • Hi,

    I’ve tried running the code with the same settings you suggested.

    1. I updated the heap and stack sizes as you recommended (screenshot attached).
    2. I also increased the memory allocation in the linker command file (please correct me if this is not the right approach).

    Even after applying these changes, I’m still not able to see the float value printed in the console.

    Could you please help me understand what might still be missing?

    Thank for your support in advance. 

    Regards, 
    Deepan

  • Hi Deepan,

    Here is the project I used:

    5518.empty_driverlib_project.zip

    Can you try this out and let me know if it works on your setup?

    Best Regards,

    Delaney

  • Hi,

    Thank you for sharing the project file. I will try out on my setup and let you know.

    Regards, 

    Deepan

  • Hi,

    I tested the project you shared, and it works correctly when I use the CPU_RAM build configuration.

    However, when I switch to CPU_FLASH (which I need in order to flash the build onto the board), I still encounter the same issue as before during debugging.

      

    I also tried the same setup with my own code where a float value is sent over UART. The issue is the same there as well: in CPU_RAM, the data is received correctly during debugging, but in CPU_FLASH, no data is received at all—even when flashing and debugging the build. We are using Tera Term to monitor the UART output.

    Let me know if you have any suggestions on what could be causing this difference between RAM and FLASH builds.

    Thanks for your support in advance.

    Regards,
    Deepan

  • Hi Deepan,

    That is odd, let me test the flash build myself and get back to you. I'm assuming the flash build somehow still isn't allocating enough heap or stack space.

    Best Regards,

    Delaney

  • Hi,

    I just wanted to follow up on the flash build testing. Please let me know if there are any updates when you get a chance.

    Regards,

    Deepan

  • Hi Deepan,

    Unfortunately, I still haven't had a chance to try the flash build myself. If you try allocating a lot more heap or stack space does it fix the issue?

    Best Regards,

    Delaney

  • Hi,

    I tried increasing the heap and stack sizes in the project properties, and I also modified the Flash linker .cmd file. However, despite these changes, I was still unable to get floating-point values to print correctly in the console.

    I have attached the screenshot of the output:

    Could you please let me know if there are any additional steps or configurations, I should try to resolve this issue?

    Thank you in advance for your support.

    Regards,

    Deepan