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.

CCS/MSP432P4111: printf on console with portable native FreeRTOS

Part Number: MSP432P4111

Tool/software: Code Composer Studio

Hi,

I try to printf on the console with a copy of the portable native FreeRTOS project.

I get no error while compiling and I dont get any output on the console.

I know that it is not a good idea to use printf in more threads. But if I use it only in one thread it should be not a problem.

I have included stdio.h and I set the stack and heap size both set to 512 bytes. But I get no output.

What else can I check and does a special "FreeRTOS" printf function exist?

Thank you very much for your help!

ccs 8.3

TI compiler 18.1.5

  • (edit) my prior answer was predicated on the impression that FreeRTOS did not work with TI Compilers. I added a bit more information. 

    Hi,

    I am not the most well versed in FreeRTOS, but I couldn't find a low overhead Console I/O call among its APIs. I found many discussions around the web that talk about the same problem (search for "freertos printf"), but no clear solution is given. 

    user5841294 said:
    But if I use it only in one thread it should be not a problem.

    Unfortunately an umbrella statement like that is not possible to be made, given that it is highly dependent on the firmware itself. Since that printf() routines usually call a SW interrupt to be able to move data to/from the host, this can easily disrupt the real-time constraints of your system, even if the call is located in a low priority task. 

    (edit) For TI Compilers, please check section 3 of the reference at the end of this post. 

    user5841294 said:
    I have included stdio.h and I set the stack and heap size both set to 512 bytes. But I get no output.

    I wouldn't be too surprised by that. The Console I/O functions are very memory hungry and, just as an example, the TI compiler requires at least 0x400 of stack and heap.

    (edit) For TI Compilers, please check sections 2.3 and 2.4 of the reference below.

    (edit) For TI Compilers, there is a way to reduce the code size required by Console I/O functions. Check section 4.1 of the reference below.

    http://processors.wiki.ti.com/index.php/Tips_for_using_printf   

    The remedy is usually use a different method of data communications - UART is a common method. 

    Regards,

    Rafael

  • Hi Tom,

    thank you for your detailed answer!

    I didn't mark this as resolved because I'm still trying to get a "printf" solution.

    I read the "Tips_for_using_printf" but at this moment I only see they way to use UART and a Terminal (Putty). The example "portableNative_MSP_EXP432P4111_freertos_ccs" has a UART implementation. The Display_printf() works with this example project. So I tryed to import this UART implementation in my project. But the Display_printf() function doesn't work - it doesn't output anything and while building I don't get an error.

    In my project I set the display init in the freertos_main.c file, it looks like this:

    .
    .
    .
    /* Display Header files */
    #include <ti/display/Display.h>
    #include <ti/display/DisplayUart.h>
    /* Display Driver Handle */
    Display_Handle displayHandle;
    .
    .
    .
    
    int main(void){
    .
    .
    .
        Display_Params displayParams;
    
        /* Halting the Watchdog */
        MAP_WDT_A_holdTimer();
    
        /* Call driver init functions */
        Board_initGeneral();
        Display_init();
    
        /* Configure & open Display driver */
        Display_Params_init(&displayParams);
        displayParams.lineClearMode = DISPLAY_CLEAR_BOTH;
        displayHandle = Display_open(Display_Type_UART, &displayParams);
        if (displayHandle == NULL) {
            Display_printf(displayHandle, 0, 0, "Error creating displayHandle\n");
            while (1);
        }
    
        Display_printf(displayHandle, 0, 0, "\r\nCS_getDCOFrequency=%u", (unsigned int)CS_getDCOFrequency());
    .
    .
    .
    
    

    I tried different stack and heap sizes but this is not the reason. Furthermore I checked the project settings but I can't the see reason that it isn't write to the Putty terminal. Maybe you can give me an advice?

    Thanks

  • Now it works!
    It works when I move the display code in a thread. It don't works if I use it as mentioned above directly in the freertos_main.c where the threads are created and started. So I will creat a display init tread which I start at first. Then in all other threads the Display_printf() should be able to use.