Other Parts Discussed in Thread: SYSBIOS, CC2650
Hi,
I want to use System_prinf in tirtos_simplelink_2_11_00_03_eng on M3 (MCU)
But I try many way my search on TI E2E but still print nothing.
Thank
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.
Hi Vincent,
In order to use System_printf() in your app, please follow below steps:
xdc.useModule('xdc.runtime.System');
#include <xdc/runtime/System.h>
Void func()
{
...
System_printf("This is test msg %d.\n", msgId);
}
System_printf() usage is very similar to printf() usage. For more info please see System_printf() cdoc here.
Best,
Ashish
Hi Vincent,
System_printf() by default uses either the SysStd or SysMin (default is SysMin) system provider. Depending on which system provider is plugged in, either putchar() or __write() is called. Both these calls use the semihosting library to print to the console in IAR. "__dwrite" is already implemented in IAR's runtime library. Which library are you linking with ?
In order for semihosting to work, you need to be connected to the debugger. If the board is running stand alone, then it is best to plug in UART to get the print msgs. Since you already have UART_write() working, you can do the following to forward all System_printf() msgs to UART:
*.cfg:
var System = xdc.useModule('xdc.runtime.System');
var SysCallback = xdc.useModule('xdc.runtime.SysCallback');
System.SupportProxy = SysCallback;
SysCallback.abortFxn = "&userAbort";
SysCallback.exitFxn = "&userExit";
SysCallback.flushFxn = "&userFlush";
SysCallback.putchFxn = "&userPutch";
SysCallback.readyFxn = "&userReady";
*.c:
Void userAbort(CString str)
{
}
Void userExit(Int val)
{
}
Void userFlush()
{
}
Void userPutch(Char ch)
{
UART_write(handle, ch, sizeof(ch));
}
Void userReady()
{
...
}
Once you do the above setup, you can use System_printf() instead of UART_write() and all your prints will be visible on the UART console.
Best,
Ashish
Hi Vincent,
Can you paste the entire build log ? Also, the function signature for userPutch() in the code you shared is incorrect. It should be "Void userPutch(Char ch)". Please fix the function signature.
Best,
Ashish
Hi Vincent,
Glad to know System_printf() is working for you now.
The System module does not support scanf() functionality. What you could do is provide your own implementation of __read() that uses UART_read() underneath. This way you will be able to use the C runtime library's scanf. Please see "IMPLEMENTING LOW-LEVEL CHARACTER INPUT AND OUTPUT" section of the IAR user guide addendum. This section explains how to implement your own version of __read and also has an example for reference.
Best,
Ashish
Ashish Kapania said:
- Include xdc.runtime.System module in your app's *.cfg file
xdc.useModule('xdc.runtime.System');
- Include System.h header in your C file and then you can make System_printf() calls.
#include <xdc/runtime/System.h> Void func() { ... System_printf("This is test msg %d.\n", msgId); }
This doesn't seem to work in IAR. it's complaining about undefined __write function.