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.

RTOS/MSP432E401Y: System_printf for data sending on uart

Part Number: MSP432E401Y
Other Parts Discussed in Thread: SYSBIOS

Tool/software: TI-RTOS

Hi..

Can any one help me in using the "System_printf" function. I am using "Nvsinternal" example, in that i want to output the base address and sector size values on to the uart.

Currently i am using UART4.

I have gone through some of the forum posts which mainly suggesting that to add the header file 

"#include <xdc/runtime/System.h>" in main file

and the below initialisation in  .cfg file.

var System = xdc.useModule("xdc.runtime.System");

var SysMin = xdc.useModule("xdc.runtime.SysMin");

SysMin.bufSize = 0;

SysMin.flushAtExit = false;

System.SupportProxy = SysMin; /* not really necessary since SysMin is the default */

But here in the example code there is no such .cfg file.

I have used that system.h header in the nvsinternal.c file and directly used System_printf function for display. however there is no output on the console.

So please explain me - how to use this "System_printf" function for sending the data out over UART4. 

Thank you

Regards

Kalyan.

  • If you can communicate via the UART, why not just use sprintf() to create a string and send it directly?

  • Hi Keith,
    Thank you for the reply.
    I read somewhere in the documents that System_sprintf()" function significantly reduces the stack burden. Where as sprintf uses a very large amount of stack memory.

    However I would like to learn the usage of both the functions. So if you could elaborate how to use those functions in sending data over the uart4 in msp432e401y it will be great .

    Thank you
    Regards
    Kalyan.
  • The examples are structured a little bit differently.  For example in the hello example in the SYSBIOS directory you can find the hello.cfg file within the project.  In the case of the nvsinternal_MSP... example you will find the .cfg in the tirtos_builds_MSP_EXP432E401Y_release_ccs project.

    Regards,

    Chris

  • Hi Kalyan,

    Have you looked at the SimpleLink Academy lab on "Debugging Output". dev.ti.com/.../

    I'd recommend you just use Display_printf and have it routed to a UART (instead of using System_printf). We have several examplse of that. You can use System_sprintf in creating the desired string (instead of sprintf).

    Todd
  • Hi Todd,
    Thank you for the reply.
    I have read the document you have suggested.

    1.With "Display_printf" function i am get the data on the IDE terminal on the virtual UART properly. However i want to get
    the data on UART4, for that in "msp432e401y.c" file. i have changed the " MSP_EXP432E401Y_UART0" to
    "MSP_EXP432E401Y_UART4" in displayUartHWAttrs.
    with that change i am not getting the data on UART4. Am i need to make some more changes for getting data on uart4?.

    2.Where as System_sprintf()" function significantly reduces the stack burden when compared to "Display_printf". So i
    want to use the System_printf function.

    For this i have used "#include <xdc/runtime/System.h>" header in nvsinternal.c file and used the function call

    System_printf("sector_size: 0x%x",regionAttrs.sectorSize);

    But i am not getting the output neither on the IDE terminal nor on the UART.
    I want to get that data on UART4.

    Help me on this.
    Thank you

    Regards
    Kalyan.
  • Hi...
    Can any one answer my above query?

    Thank you

    Regards
    Kalyan.
  • Regarding #2: Note that System_sprintf is an alternative for sprintf. Display_printf and System_printf are alternative for printf. You can use System_sprintf to help form a string that you using in Display_printf. Please refer to System_sprintf (or sprintf) documentation to get an understanding of what the API is used for.

    Todd
  • You have 256K of RAM. I don't think stack space is an issue. If System-printf() saves on stack space it is because it is offloading to the host PC.

    As far as "functions" for UART communication, check out the PC Echo examples. They are for the back-channel UART, but you can easily change them to UART4.
  • Hi Keith,

    I believe you are thinking of Log_printf (which only acts on binary data and not ASCII)...System_printf does the string manipulation on the target (and that's why it chews up stack space and is relatively slow).

    Todd
  • Hi Todd,
    Thank you for the reply.
    What about my first question.How to divert the data on to uart4 using Display_printf.
    Regarding my second question: I have gone through the documents you mentioned.It says that - add an header file and use the system_printf function. If required i will attach the code tomorrow.

    Please clarify me.

    Thank you
    Kalyan.
  • Hi keith,
    Which examples are you mentioning. Is it uartecho?
    As per that example i have changed the code as mentioned earlier.However the data is not coming on that port. 

    Kalyan.

  • Then it is time to share your code.
  • nvsinternal_MSP_EXP432E401Y_tirtos_ccs.zip

    Hi keith..

    Please go through the code i have attached.

    Only changes i have made for diverting the data sending from "Display_printf" function to uart4 was, i replaced "MSP_EXP432E401Y_UART0" to "MSP_EXP432E401Y_UART4" in displayUartHWAttrs.

    With this... i am not even getting the "UART_Write" messages on uart4.

    If i keep it as MSP_EXP432E401Y_UART0,   UART_Write messages are coming on uart4 and Display_printf messages are on IDE terminal.

    And also please look at the  "System_printf". I am not getting any messages neither on UART4 nor on IDE terminal.

    Thank you

    Kalyan

  • Hello Keith,
    Have you gone through the attached code.

    Kalyan.
  • Please review the changes that you have made. The MSP_EXP432E401Y_UART0 is an enumeration found in MSP_EXP432E401Y.h and used to index the definitions found in the UART configuration of MSP_EXP432E401Y.c. Here you find definitions for UART base address and UART pin assignments.

    Regards,
    Chris
  • Hello chris,
    Have you seen the attached code in the previous post.
    I have already made changes in MSP_EXP432E401Y.c file for uart 4 configuration like UART base address and UART pin assignments.
    Could you please run the attached code at your side.

    Thank you

    Regards
    Kalyan.
  • Hello,

      Looking at your code you have allocated the resource UART4 to both the display and the UART.  When you call

    displayHandle = Display_open(Display_Type_UART, NULL);  

    and then call

       uart    =   UART_open(Board_UART4, &uartParams);

    The open fails because the UART4 is already in use.  

    If I change the Display configuration back to UART0

    .uartIdx = MSP_EXP432E401Y_UART0,

    then I can see information on both UARTs.

    Regards,
    Chris

**Attention** This is a public forum