I would like to use the printf() function in a new bareboard project. I included the necessary files: (ConsoleIO.c, ConsoleIO.h, PDD_Types.h, and UART_PDD.h). My project builds successfully but when it was run in debug, it keeps getting suspended by some interrupt handler, shown in screenshot below:
Updated 10/29/2015:
ZhangJennie: Can't seem to reply to your post...
Anyway, thanks for responding, but this article How to use printf() to print string to Console and UART in KDS2.0 didn't help... ConsoleIO.c already has all the write and read functions written.
Any other ways to troubleshoot this without PE or using the example projects?
Thanks.
Hi,
I just made a testing project with TWR-K60N512 board. printf can print to console without problem.
files under C:\Freescale\CW MCU v10.6.4\MCU\ARM_GCC_Support\UART\TWR-K60N512
are based on TWR-K60N512, please make sure you use the right board.
make sure your project is based on K60N512 chip.
Connect your host with the 9pin serial connector on the TWR-SER board, configurated for 38400 baud.
for detail, please see my testing project and video.
can this help you?
Have a great day,
Zhang Jun
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Zhang Jun,
I really appreciate your help! I selected PK60N512 instead of MK60DN512Z or MK60DN512 (not sure if this actually makes any difference at all...) and also enabled OSJTAG protocol, debugged in flash mode, that seemed to have stopped my program from being suspended. I'm assuming printf() will work with the 9pin serial, which I don't have one at the moment to test, will do at the end of the day and let you know how that goes.
I'm more interested to know which UART and port to change in 'ConsoleIO.c' so that I can use the printf() function through USB instead 9pin serial, just like in the examples. Could you point me in the right direction?
Thanks!
yes, if you didn't select the collect chip in your project, it's possible of having problem as yours.
if you want to use Virtual CDC USB serial port, you need revise ConsoleIO_Init() to use the correct pins.
Erich article talks about this topic:
printf() with the FRDM-KL25Z Board and without Processor Expert | MCU on Eclipse
or you can tell me your TWR board part number, I will check.
Have a great day,
Zhang Jun
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
My TWR board part number is TWR-K60N512. Hope that helps.
Thanks.
per TWR-K60N512 schematic and user manual, you need revise ConsoleIO_Init() to use PTE9 and PTE8
please refer Erich's article for how to revise
printf() with the FRDM-KL25Z Board and without Processor Expert | MCU on Eclipse
can this help you?
Have a great day,
Zhang Jun
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Zhang Jun,
Hmmm, I followed the instructions, but my program was suspended again by the same interrupt handler when printf() is included...
Couldn't find an option to attach my source code, so here's a screenshot of it:
Hmmm, any ideas?
Quick question: what does (typecast) NOT (typecast) mean, specifically (uint32)~(uint32) at line 233?
Thanks.