ConsoleIO printf problem

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

ConsoleIO printf problem

跳至解决方案
3,294 次查看
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?

标签 (1)
0 项奖励
回复
1 解答
2,409 次查看
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 项奖励
回复
3 回复数
2,409 次查看
BlackNight
NXP Employee
NXP Employee
0 项奖励
回复
2,409 次查看
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 项奖励
回复
2,410 次查看
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 项奖励
回复