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.

MSPM0C1106: How to enable the floating point printf(); function output with Keil

Part Number: MSPM0C1106


Tool/software:

Hi Expert

Customer feedback with the printf(); function the floating point data cannot be printed through SCI properly, but with L1306 device the function can work well with floating point data. I see in CCS setup there is the choice for how to build the STDIO function: How to enable floating-point value print? but how to do it with Keil?

Thanks

Joe

  • Dose customer can print fix-point value with no issue in Keil?

    I not recommend to to printf(); in M0, it will take much of resources, memory and cpu load. Recommend to print the value by the UART directly.

  • Dose customer can print fix-point value with no issue in Keil?

    Correct.

    I looked into other discussions, seems that MSPM0 serials can support the full spec stdio, and there is no issue to print the floating point data with L1306. so I'm curious about whether there is a build setting on this lib.

    I not recommend to to printf(); in M0, it will take much of resources,

    It is required by customer debug routine, so need to use this function in development, but will block the function once device goes to mass production.

    Thanks

    Joe

  • Also not familiar such function with Keil, for CCS that is easy just to include the stdio.h and you can print it in the console. You can ask customer go to Keil's support form to get the expert there

  • Hi Gary

    I test the printf() function in the C1106 project in ccs, seems there is some issue: 

    If I add the printf() function as below, then click build, the console window will report a warning.

    If i ignore the warning and start to debug the code, the project will stop at cinit function but not the first line of main function, then I click run the project will finally run into the main loop, but I cannot see anything printed in the console window.

    but if I follow the warning move out the .cmd file manually as discussed in E2E thread, then add the -heap define, the project build will report issue.

    even if I change the -heap size to 0x100 which is smaller than default, the same issue will also be reported.

    Thanks

    Joe

  • Please refer to this code

    gpio_software_poll_LP_MSPM0C1106_nortos_ticlang.zip

    And monitor the value in the CIO column

    It seems to add the puts(""); to make the printf to work, more information you can also refer to this page

    https://software-dl.ti.com/ccs/esd/documents/sdto_cgt_tips_for_using_printf.html 

  • Hi Gary 

    Thanks for your support, I use your demo can make printf work, but there are 2 questions:

    If I change the variables from int to float, then the CIO output data is wrong.

    Why the puts("") function is needed for the printf, seems there is no more description in the link you shared.

    Thanks

    Joe

  • I don't know about that, let me move this thread to CCS team to see if any comments there

  • I don't have a C1106, but on the L1306 I observed: (a) CIO takes just under 512 bytes of heap space (b) printf (the core function) takes well in excess of 256 bytes of stack space (I vaguely recall something like 350 bytes). The (software) floating point support probably adds (a small bit) to that.

  • The code in this example project ...

    Please refer to this code

    gpio_software_poll_LP_MSPM0C1106_nortos_ticlang.zip

    And monitor the value in the CIO column

    ... contains these source lines ...

            printf("value:%d", ii);
    
            puts("");
    

    Notice the printf call does not print the newline character \nprintf writes output to the default stream stdout.  This stream is line buffered, which means output is written only when newline is seen, or the buffer is full.  The function puts is defined to always write a newline character at the end of the string, even if it is an empty string.  This code is equivalent ...

            printf("value:%d\n", ii);
    

    I suspect a similar change will fix the problem.

    Thanks and regards,

    -George