9 years, 12 months ago.

Can I use the internal oscillator in the KL46Z in place of the external crystal?

I am wondering if the internal oscillator can be used in place of the external crystal. I am not using USB (which I hear you need the external oscillator for). I would like the MCU to behave like it does on the FRDM boards, just without an external crystal. This is for the KL46Z. The reason I want to use the internal oscillator is because I want to save space on a custom PCB. How would the frequency be set?

1 Answer

9 years, 12 months ago.

Yes you can :)

Throw away your mbed lib, import mbed-src instead: http://mbed.org/users/mbed_official/code/mbed-src/. Same library, but the not-precompiled version, so you can change the source code. There go to this file: http://mbed.org/users/mbed_official/code/mbed-src/file/033f1c328f6e/targets/cmsis/TARGET_Freescale/TARGET_KLXX/TARGET_KL46Z/system_MKL46Z4.c

The default there is 8MHz external oscillator, with PLL upconverted to 48MHz. You can manually make any clock setup you want there, for example you can also use the 4MHz internal oscillator and then the PLL, but then you need to manually do it (or google someone elses code which does it). However as you can see there is also one predefined setup which does not use an external crystal: Setup 0. It uses the internal 32kHz oscillator and upconverts it to almost 42MHz. There will be some small errors in timer libs, both because it now uses less accurate internal oscillators, and because it isn't exactly 42MHz, but those are fairly small and will generally not be an issue. Since it doesn't use external oscillators you can simply test it on your regular KL46Z board.

(It does define an 8MHz crystal in the code, but it doesn't do anything with it, the mbed libs will purely use internal clock sources when it runs from an internal oscillator).

Accepted Answer

Do you know if the 8MHz internal oscillator can be upconverted? Looking at Figure 5-1 page 124 of the reference manual makes me think that it isn't.

posted by Andrew Albing 29 Apr 2014

4MHz internal oscillator. But you are correct, my bad. I just assumed it was possible, because well, why not? But it indeed seems to be only capable of running on an external oscillator. So then you are 'stuck' with just the FLL solution, which will generally be fine too. (On the KL05 it is the standard, only then with external 32kHz crystal).

posted by Erik - 29 Apr 2014