Custom printf

Description

The custom printf (cprintf.c) is useful to switch the printf outputs to different devices such as UART, USB or network.     If CPrintf's are used make sure the stack is large enough. Depending on tools version, DSP architecture or conversion parameter the required stack size varies and may take more than 600 bytes/words. It is recommended to define a stack size of at least 0x400.


Enable output device

To enable a new output channel, add (or uncomment) the needed code and uncomment the CPRINTF_xxx_AVAILABLE define in BoardSpecific.h:

#define CPRINTF_CCS_AVAILABLE TRUE
//~ #define CPRINTF_UART_AVAILABLE TRUE
//~ #define CPRINTF_USB_AVAILABLE TRUE
//~ #define CPRINTF_NET_AVAILABLE TRUE




Select output device

To select the output device use function

The first CPrintf_select_output() function call should be used to initialize a link. E.g. if a UART is used, call InitializeUART() once to set the appropriate parameters.
Possible parameters for device:

CPRINTF_USB_OUTPUT
CPRINTF_NET_OUTPUT




Example

CPrintf_select_output() can be used to switch different outputs to different devices. E.g.:

CPrintf ("This output goes to CCS\r\n");
CPrintf ("The output has been changed to UART\r\n");
CPrintf ("Output switched back to CCS\r\n");

If needed a debug level can be introduced to automatically switch between different output devices.




External links

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