我想弄清楚:kl25z 在iar 里怎么设定频率?
本来也不想去了解这的,能运行就可以了的。可我想移植cmsis 的usb stack。别人这么写的:
此外,针对该工程还需要修改两个部分,一是需要配置时钟部分PLL锁相环的倍频系数,使其倍到96M(因为USB的时钟源为MCGPLL/2=48),即修改freedom.h中PLL0_VDIV参数为48,然后由于PLL输出96M,其Coreclock和busclock的配置需要保证SIM_CLKDIV1 = SIM_CLKDIV1_OUTDIV1(1) | SIM_CLKDIV1_OUTDIV4(1);即Coreclock=48MHz,Busclock=24M。
整个freedom.h 文件如后面清单。
其中关键修改的是
//#define PLL0_VDIV 24 // multiply reference by 24 = 48 MHz
#define PLL0_VDIV 48 // multiply reference by 48 = 96 MHz
不做这个修改usb 不能启动,修改了系统频率为96M , 结果系统不能启动。
不知道相应在哪里还要做修改。
他的程序包是可以运行的,可我做的就是不行。
freedom.h 文件内容:
/*
* File: freedom.h
* Purpose: Kinetis Freedom hardware definitions
*
* Notes:
*/
#ifndef __FREEDOM_H__
#define __FREEDOM_H__
#include "mcg.h"
/********************************************************************/
/* Global defines to use for all Tower cards */
#define DEBUG_PRINT
// Define which CPU you are using.
#define CPU_MKL25Z128LK4
/*
* Input Clock Info
*/
#define CLK0_FREQ_HZ 8000000
#define CLK0_TYPE CRYSTAL
// Uncomment this next line if you desire the clock output
//#define ENABLE_CLKOUT
/*
* PLL Configuration Info
*/
//#define NO_PLL_INIT // define this to skip PLL initilaization and stay in default FEI mode
/* The expected PLL output frequency is:
* PLL out = (((CLKIN/PRDIV) x VDIV) / 2)
* where the CLKIN is CLK0_FREQ_HZ.
*
* For more info on PLL initialization refer to the mcg driver files.
*/
#define PLL0_PRDIV 4 // divider eference by 4 = 2 MHz
//#define PLL0_VDIV 24 // multiply reference by 24 = 48 MHz
#define PLL0_VDIV 48 // multiply reference by 48 = 96 MHz
/* Serial Port Info */
/**************************************************************************
* Note:
*
* Because of the changes to the UART modules, we can no longer define
* the TERM_PORT as a base pointer. The uart functions have been modified
* accommodate this change. Now, TERM_PORT_NUM must be defined as the
* number of the UART port desired to use
*
* TERM_PORT_NUM = 0 -- This allows you to use UART0; default pins are
* PTA14 and PTA15
*
* TERM_PORT_NUM = 1 -- This allows you to use UART1; default pins are
* PTC3 and PTC4
*
* TERM_PORT_NUM = 2 -- This allows you to use UART2; default pins are
* PTD2 and PTD3
*
*************************************************************************/
/* Uses UART0 for both Open SDA and TWR-SER Tower card */
#define TERM_PORT_NUM 0
#define TERMINAL_BAUD 115200
#undef HW_FLOW_CONTROL
#endif /* __FREEDOM_H__ */
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
很好的经验分享,谢谢楼主。
一周热门 更多>