ConsoleIO printf problem

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ConsoleIO printf problem

Jump to solution
2,270 Views
andrewparlane
Contributor IV

Hi,

 

I'm new to the Kinetis family of chips, code warrior and processor expert. However am reasonably experienced in embedded software.

 

I'm having trouble getting printf to work on my FRDM-K20D50M board.

 

Setting up the Serial_LDD component to use UART0 on PTB16 and PTB17. Then using:

AS1_SendBlock(AS1_DeviceData, "hello world\n", 12);

 

This works fine.

 

I then add a consoleIO component, and try:

printf("Test\n");

 

This doesn't work.

 

Stepping through it I end up in:

C:\Freescale\CW MCU v10.5\MCU\ARM_GCC_Support\ewl\EWL_C\src\stdio\printf.c

 

Sticking breakpoints in the generated CsIO1.c __write_console and _write functions. They are never hit.

Instead the code goes through fwrite(), with the file pointer: stdout. However I can't see anywhere that sets up stdout to point to my UART.

 

In addition in the generated CsIO1.c the code uses: UART1_BASE_PTR. Whereas my serial component is configured to UART0.

 

I noted that at the path that usses ARM_EABI_Support, there is:

C:\Freescale\CW MCU v10.5\MCU\ARM_EABI_Support\ewl\EWL_C\src\printf.c

 

This printf.c has a lot more code, including: printf_console, which references __write_console.

 

It compiles and uses this file when I select the freescale tools instead of ARM tools. However this still doesn't work, however it does get into CsIO1.c this time. It may be the UART1_BASE_PTR that breaks it here.

 

I'm sure I'm missing something obvious, but I just can't see it. Any ideas?

Labels (1)
0 Kudos
1 Solution
1,385 Views
andrewparlane
Contributor IV

I fixed it.

This post had the answer.

Re: printf in TeraTerm

The problem was I added a serial_ldd component and a ConsoleIO component. The ConsolieIO component auto adds a serial_ldd.

View solution in original post

0 Kudos
3 Replies
1,385 Views
BlackNight
NXP Employee
NXP Employee
0 Kudos
1,385 Views
andrewparlane
Contributor IV

I found and read that already. Unfortunately it doesn't help. I'm using the EWL library, I have a consoleIO component and I have a serial_ldd component. When I just using the serial's sendBlock function, I see the output. The problem is the printf being compiled in as part of the GCC tools isn't linking up with the consoleIO component. In addition the consoleIO component doesn't seem to link to the serial component and instead tries to do the comms itself and ends up using the wrong UART peripheral.

0 Kudos
1,386 Views
andrewparlane
Contributor IV

I fixed it.

This post had the answer.

Re: printf in TeraTerm

The problem was I added a serial_ldd component and a ConsoleIO component. The ConsolieIO component auto adds a serial_ldd.

0 Kudos