在线时间0 小时
UID425826
注册时间2013-4-9
NXP金币0
该用户从未签到
中级会员
 
- 积分
- 302
- 最后登录
- 1970-1-1
|
急求各位大大帮忙!哪位好心大大能尽快给我回复啊,我这边一块新板子急等着,硬件是外接的外部32768HZ时钟,我软件上的配置如下:
调用官方提供的driver里面的mcg.c里面的 fei_fee()函数,给的参数分别为: crystal_val - external clock frequency in Hz: 32768 hgo_val - selects whether low power or high gain mode is selected * for the crystal oscillator. This has no meaning if an * external clock is used. :0 erefs_val - 0 (即选择无源晶振), 但是程序在最后检测状态:if (!(MCG_S & MCG_S_IREFST_MASK)) break; 的时候没有跳出,即没有进入FEE模式,求问是程序问题还是硬件问题? 程序问题的话急求配置方法,感谢!硬件的话请问应该怎么检查???? 2013.12.17.自己结了这个帖吧。软件配置的问题:以上配置erefs_val应改为1:外部晶振选择。(这里我也还是没理解清楚,以前以为是区分的无源和有源,现在看只是外部晶振/体和EXT reference clk的区别...). 另外软件还没有配置好时,确实测不到硬件起振。但是硬件连接应该按照如上的Low-frequency (32 kHz), low-power选择connection 1,即不需要任何外围电路,配置内部电容。附fei_fee代码(官方有几个版本,主要是OSC0_CR的配置有的有,有的没有。) 附: <blockquote style="padding-left: 1ex; margin: 0px 0px 0px 0.8ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid; ">int fei_fee(int crystal_val, unsigned char hgo_val, unsigned char erefs_val) { unsigned char frdiv_val; unsigned char temp_reg; // short i; int mcg_out, fll_ref_freq, i; // check if in FEI mode /* if (!((((MCG_S & MCG_S_CLKST_MASK) >> MCG_S_CLKST_SHIFT) == 0x0) && // check CLKS mux has selcted FLL output (MCG_S & MCG_S_IREFST_MASK))) // check PLLS mux has selected FLL
{ return 0x1; // return error code } */
// check external frequency is less than the maximum frequency if (crystal_val > 50000000) {return 0x21;} //check crystal frequency is within spec. if crystal osc is being used if (erefs_val) { if ( ((crystal_val > 40000) && (crystal_val < 3000000)) || (crystal_val > 32000000)) {return 0x22;} // return error if one of the available crystal options is not available }
// make sure HGO will never be greater than 1. Could return an error instead if desired. if (hgo_val > 0) { hgo_val = 1; // force hgo_val to 1 if > 0 }
OSC0_CR = OSC_CR_ERCLKEN_MASK |OSC_CR_EREFSTEN_MASK |OSC_CR_SC8P_MASK; //|OSC_CR_SC4P_MASK;
// configure the MCG_C2 register // the RANGE value is determined by the external frequency. Since the RANGE parameter affects the FRDIV divide value // it still needs to be set correctly even if the oscillator is not being used temp_reg = MCG_C2; temp_reg &= ~(MCG_C2_RANGE0_MASK | MCG_C2_HGO0_MASK | MCG_C2_EREFS0_MASK); // clear fields before writing new values <blockquote style="padding-left: 1ex; margin: 0px 0px 0px 0.8ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid; "><font face="arial"><span style="font-size: 14px; line-height: 23px;"> if (crystal_val
|
|