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.

Getting printf working with TivaWare; difference between CC**00 vs Tivaware vs TI-RTOS?

Hello, 

I have TM4C1294XL launchpad. 

I would like to use 

#include <stdio.h>
#include <string.h>
#include "inc/tm4c1294ncpdt.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"


#define PERIPH SYSCTL_PERIPH_GPION
#define GPIO_BASE GPIO_PORTN_BASE
#define GPIO_PIN GPIO_PIN_1


int main() {
uint32_t g_ui32SysClock;
	g_ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
	                SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |
	                SYSCTL_CFG_VCO_480), 120000000);

	SysCtlPeripheralEnable(PERIPH);

	GPIOPinTypeGPIOOutput(GPIO_BASE, GPIO_PIN);
	SysCtlDelay(3);
	
	UARTStdioConfig(0, 115200, g_ui32SysClock);
	volatile uint32_t ui32Loop;
	while (1) {
		GPIOPinWrite(GPIO_BASE, GPIO_PIN, GPIO_PIN);

		for (ui32Loop = 0; ui32Loop < 200000; ui32Loop++);

		GPIOPinWrite(GPIO_BASE, GPIO_PIN, 0);
		for (ui32Loop = 0; ui32Loop < 200000; ui32Loop++);

		printf("I am alive"); // tivaware/utils/uartstdio.c:UARTwrite(const char *, int) works fine here, but I want to handle stdout using this uart.

	}
}

Those are my arguments to the compiler in CCSv6.0.1

"c:\\ti\\ccsv6\\utils\\bin\\gmake" -k all 
'Building file: ../hello.c'
'Invoking: ARM Compiler'
"c:/ti/ccsv6/tools/compiler/arm_5.1.6/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 --abi=eabi -me --include_path="c:/ti/ccsv6/tools/compiler/arm_5.1.6/include" --include_path="C:/Users/ugps/workspace_v6_0/mt/mt_eth_btldr" --include_path="C:/ti/TivaWare_C_Series-2.1.1.71/boot_loader" --include_path="C:/ti/TivaWare_C_Series-2.1.1.71" -g --gcc --define=ccs="ccs" --define=PART_TM4C1294NCPDT --display_error_number --diag_warning=225 --diag_wrap=off --printf_support=full --preproc_with_compile --preproc_dependency="hello.pp" --define=DEBUG "../hello.c"

I am aware of webpages like:

processors.wiki.ti.com/index.php/Tips_for_using_printf - but I feel it is for TI-RTOS... but unluckily there are no requiremenets specified... since I am new I do not even know what are prerequisites to use it... 

http://www.ti.com/lit/ug/spru187u/spru187u.pdf page 224 - adding new device, but 

    add_device("mydevice", _MSA, MYDEVICE_open, MYDEVICE_close, MYDEVICE_read, MYDEVICE_write, MYDEVICE_lseek, MYDEVICE_unlink, MYDEVICE_rename);

As you can also see I have tried using --printf_support flag... 

I would like to be able to see printf's output in the console. 

I do not necesarrly need RTOS, I am working on some simple applications but I do not want to run purry nor hyperterminal all the time... 

And another question? What is difference between CC5000, Tivaware and TI-RTOS?

  • Hello Artur

    1. You can use the UARTprintf by compiling the uartstdio.c in your project. The final output would be on a Hyperterminal Console
    2. TI RTOS as the name indicates is a RTOS. TivaWare is the bare metal implementation of API calls that can be used to implement a embedded code. It is also used inside the TI RTOS's high level function.

    Regards
    Amit
  • I have commented this in source code that I am aware of `uartstdio.c` (and I am adding it via RMB on project>"Add Files..." from `utils` directory of course), but I want to force `printf` to print to CCS's console.
  • Hi Artur,

    >but I want to force `printf` to print to CCS's console.

    You might possibly can make a terminal window using GUI composer launched inside CCS. Don't believe it is possible or highly difficult to output printf text direct to the CCS console window. That is unless Eclipse will support C hook links into the console tab but I highly doubt they do.
  • Artur said:
    but I want to force `printf` to print to CCS's console

    The CIO Breakpoint is used to allow printf output to be displayed in the CCS Console.

    Insufficient heap or stack space can cause printf to fail:

    a) If there is insufficient stack space printf can cause a crash.

    b) If there is insufficient heap space printf can't allocate the CIO buffer, meaning the printf output is silently discarded.

    From memory, a heap size of at least 1024 bytes and a stack size of at least 1024 bytes is sufficient to allow a printf call to display output on the CCS Console.

    Also, the printf output is line buffered, so unless there is a '\n' character the output may not appear on the CCS Console.

  • Hi Chester,

    Brilliant as many your posts are adding CIO break point halts the MPU. Struck me after reading your post Artur may be unaware Hyperterm still receives data during CCS debug Run application. That scenario added to the CIO break point you bring to the table also tasks the Windows USB serial CDM driver. Especially true if multiple printf positions exist and random crashes occur in the application on either side of the link. Not sure Linux is supported in that CDM serial USB driver is perhaps one reason for Artur post.

    >b) If there is insufficient heap space printf can't allocate the CIO buffer, meaning the printf output is silently discarded.

    FYI: The default TI example project builds with (LWIP heap) have Clib (0) heap in the linker configuration. In that case UARTprintf outputs data with only a Stack configured. Post in the CCS forum and wiki pages contradict just that topic of Clib heap. Until that printf heap question is answered remains debatable if it is even required. Looks like a typo to me or misquote.

    e2e.ti.com/.../1628581