I can't get UART to work when I change the clock configuration form the default. This can be recreated by setting up a new project with KSDK 1.3, modifying the UART non blocking example to work in the new project, and the adding
#define CLOCK_SETUP 1u
to the system_MK64F12.h file. If the clocks are left to run at the default speed, UART works perfectly.
I've included my example as an attachment. I am using the FRDM K64F board.
Original Attachment has been moved to: SerialTest.zip
已解决! 转到解答。
Hello Seth,
The UART can work at the max clock configuration.
The project you attached have some problem, you use the PEE mode ,
use the system oscillator 0 reference clock , while you do not define it ,
so you can check , when you project run to
clock = CLOCK_HAL_GetOutClk(MCG_BASE);
the "clock" is 0 .
You can directly add the "board" folder refer to the demo under KSDK,
it define the system oscillator 0 reference clock at the file of board.h :
/* OSC0 configuration. */
#define OSC0_XTAL_FREQ 50000000U
I also change your project and send to you , it can work well now .
Hope it can helps you !
Have a great day,
Alice Yang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hello Seth,
The UART can work at the max clock configuration.
The project you attached have some problem, you use the PEE mode ,
use the system oscillator 0 reference clock , while you do not define it ,
so you can check , when you project run to
clock = CLOCK_HAL_GetOutClk(MCG_BASE);
the "clock" is 0 .
You can directly add the "board" folder refer to the demo under KSDK,
it define the system oscillator 0 reference clock at the file of board.h :
/* OSC0 configuration. */
#define OSC0_XTAL_FREQ 50000000U
I also change your project and send to you , it can work well now .
Hope it can helps you !
Have a great day,
Alice Yang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Thanks Alice, you rock!
I actually had the same issue with another function reading g_xtal0ClkFreq as 0. Unfortunately, I wasn't able to tell where that should have been defined or how to do it, so I actually ended up hard coding it
It's looks like the startup code that comes in the Startup_Code folder does everything bare metal without using the SDK, and as a consequence certain globals that the SDK requires do not get set.
I haven't had a chance to get as deep into the MCG documentation as some of the other peripherals, but it looks like the Clock_Init() function is basically redoes everything that the startup code already did, but set up some important globals in the process. Is the preferred way to do things?
Last, the functions in the "board" folder seem to be able to get called without adding that path in the Cross ARM C Compiler Includes, or using including them in main. Is this folder of special significance? Are the files also special? I've looked for documentation on the KDS project folder structure, but haven't been able to find any so far.
Thank you very much!
Seth Tucker