FRDM-KL05Z Code Warrior Processor Expert

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

FRDM-KL05Z Code Warrior Processor Expert

Jump to solution
983 Views
danreltek
Contributor III

Hi,

I've created a LED Blink Project in CodeWarrior 10.6, using Processor Expert as described in the help section under Processor Expert Tutorials.It works beautifully. I've now extended the project by adding component AsynchroSerial. I can send characters out no problem. But what I would like to do is use printf and all the other standard io functions. When I try to include these headers there seems to be no end to errors. I am unsure if they are even compatible with the code generated by processor expert. So before I dent my forehead too badly against my keyboard, can someone please tell me which headers to include, and how to include them in order to get to get printf to work.

Thanks

Dan

Labels (1)
0 Kudos
1 Solution
632 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Dan:

A detailed tutorial on how to use printf and the like with Processor Expert is in the next link, created by colleague Erich Styger:

Tutorial: Printf() with (and without) Processor Expert | MCU on Eclipse

You will notice however that it is not recommended to use it, or use it only during prototyping phase, as explained in other of his posts:

Why I don’t like printf() | MCU on Eclipse

Regards!,

Jorge Gonzalez

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
6 Replies
633 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Dan:

A detailed tutorial on how to use printf and the like with Processor Expert is in the next link, created by colleague Erich Styger:

Tutorial: Printf() with (and without) Processor Expert | MCU on Eclipse

You will notice however that it is not recommended to use it, or use it only during prototyping phase, as explained in other of his posts:

Why I don’t like printf() | MCU on Eclipse

Regards!,

Jorge Gonzalez

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
632 Views
danreltek
Contributor III

OK. I see why printf() is unpopular. I am happy to use puts() instead. I'm still having trouble understanding

1. where the right header file is

2. how to include it to the project

3. which project folder to include it to.

I'd appreciate some help please.

Thanks

Dan

0 Kudos
632 Views
BlackNight
NXP Employee
NXP Employee

As for including header files, it should be enough to use

#include <stdio.h>

Otherwise: you would need to post more information (your project, the errors you are seeing, etc).

Erich

632 Views
danreltek
Contributor III

OK. When I

#include <stdio.h>

I get no problem. Project builds ok.

When I add this 1 line of code:

puts("A");

I get the following result:

**** Build of configuration FLASH for project BMS_01 ****

"C:\\Freescale\\CW MCU v10.6\\gnu\\bin\\mingw32-make" -j6 all

'Building file: ../Sources/main.c'

'Executing target #2 ../Sources/main.c'

'Invoking: ARM Ltd Windows GCC C Compiler'

"C:/Freescale/CW MCU v10.6/Cross_Tools/arm-none-eabi-gcc-4_7_3/bin/arm-none-eabi-gcc" "../Sources/main.c" @"Sources/main.args" -MMD -MP -MF"Sources/main.d" -o"Sources/main.o"

'Finished building: ../Sources/main.c'

' '

'Building target: BMS_01.elf'

'Executing target #19 BMS_01.elf'

'Invoking: ARM Ltd Windows GCC C Linker'

"C:/Freescale/CW MCU v10.6/Cross_Tools/arm-none-eabi-gcc-4_7_3/bin/arm-none-eabi-gcc"    @"BMS_01.args" -o"BMS_01.elf"

C:/Freescale/CW MCU v10.6/MCU/ARM_GCC_Support/ewl/lib/armv6-m\libuart.a(uart_console_io.o): In function `__init_uart_console':

ARM_GCC_Support/ewl/EWL_C/src/sys/uart_console_io.c:200: undefined reference to `InitializeUART'

C:/Freescale/CW MCU v10.6/MCU/ARM_GCC_Support/ewl/lib/armv6-m\libuart.a(uart_console_io.o): In function `__read_console':

ARM_GCC_Support/ewl/EWL_C/src/sys/uart_console_io.c:93: undefined reference to `ReadUARTN'

C:/Freescale/CW MCU v10.6/MCU/ARM_GCC_Support/ewl/lib/armv6-m\libuart.a(uart_console_io.o): In function `__init_uart_console':

ARM_GCC_Support/ewl/EWL_C/src/sys/uart_console_io.c:200: undefined reference to `InitializeUART'

C:/Freescale/CW MCU v10.6/MCU/ARM_GCC_Support/ewl/lib/armv6-m\libuart.a(uart_console_io.o): In function `__write_console':

ARM_GCC_Support/ewl/EWL_C/src/sys/uart_console_io.c:151: undefined reference to `WriteUARTN'

mingw32-make: *** [BMS_01.elf] Error 1

I get the feeling there is something I need to do to connect the functionality of puts() with the functionality of the component AsynchroSerial.

Can they even be connected?

If so, How?

Thanks

Dan

0 Kudos
632 Views
BlackNight
NXP Employee
NXP Employee

AsynchroSerial does provide you all the low level functions needed for the EWL printf() or puts().

You need to add your own functions implementing InitializeUART(), ReadUARTN() and WriteUARTN().

You might have a look at http://mcuoneclipse.com/2013/04/17/printf-with-the-frdm-kl25z-board-and-without-processor-expert/

and Tutorial: printf() and “Hello World!” with the Freedom KL25Z Board | MCU on Eclipse which outlines the basic steps.

Erich

0 Kudos
632 Views
danreltek
Contributor III

Actually, I've just reread your advice on how to use printf() and I got rid of AsynchroSerial and replaced it with ConsoleIO. No errors!

Thanks.

0 Kudos