Using external reference

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Using external reference

跳至解决方案
708 次查看
jimclay
Contributor II

We have built a custom board that has a MK61FN1M0CAA12 chip.  We want to use the OSC0 external crystal (32 MHz) as the reference for the system clocks and we are using the example outlined in section 25.5.3.1 of the K61 reference manual (rev 2), "Example 1: Moving from FEI to PEE Mode with OSCO..." as a guide.  The code is below-

  // Enable the external oscillator, and give it an 8pF load

  OSC_CR = 0xA2;

  // Select the external oscillator as the reference, and set it to

  // Very high frequency range oscillator and high gain.

  MCG_C2 = 0x2C;

  // Wait for the crystal to finish initializing

  while ((MCG_S & 0x02) == 0);

  // Select crystal as source for MCGOUTCLK and FLL, divide it by 1024 to get it to 32 kHz

  MCG_C1 = 0xA8;

  // Wait for the FLL to use the external clock

  while ((MCG_S & 0x10) != 0);

It hangs at this point.  I have verified that the oscillator is running at 32 MHz, as expected.  Am I doing something wrong in the code?

标记 (3)
0 项奖励
1 解答
494 次查看
jimclay
Contributor II

The problem turned out to be the high-gain setting for the external crystal.  I changed the MCG_C2 setting to 0x24, and that fixed the problem.

We have a 1 MOhm load resistor which I thought made it so that you were supposed to use the high-gain setting, but I guess not.

在原帖中查看解决方案

0 项奖励
1 回复
495 次查看
jimclay
Contributor II

The problem turned out to be the high-gain setting for the external crystal.  I changed the MCG_C2 setting to 0x24, and that fixed the problem.

We have a 1 MOhm load resistor which I thought made it so that you were supposed to use the high-gain setting, but I guess not.

0 项奖励