How to use multiple clock configurations?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to use multiple clock configurations?

919 Views
ky3orr
Contributor II

Hello,

I am using KL05 and I'd like to set two clock configurations with PE in KDS2.0.

First one uses internal fast oscillator with core clock and bus = 4[MHz]. This is intended for normal run mode where fastest possible SPI communication (for this oscillator) is needed.

Second is for low power mode where core clock would be reduced to 1[MHz] (derived from fast internal oscillator) and bus clock to the lowest possible as it will not be used.

Low power mode I want to use to sleep the device but with precise timing (oscillator would be calibrated in run mode).

I'd like to exit low power mode on some timer interrupt, for example after 60[s].

I am a bit lost in clock configurations now...

Is it possible? In low power modes core clock is off. How about systick and TIMER_INT component that uses SYST_RVR as periodic interrupt source?

Second thing is how to use multiple clock configurations and how to switch between them in run time?

Thanks in advance for any hints.

Labels (1)
0 Kudos
3 Replies

684 Views
mjbcswitzerland
Specialist V

Hi Grzegorz

Setups for clocking from the 4 MHz IRC are very simple and I if you need to use PE (which will generate a large amount of code but use only use three instructions of it) you can do so for the 4MHz case.

This is shown below.

To switch between 4MHz and 1 MHz you just need to do

MCG_SC = 0x00; (4MHz)

and

MSC_SC = 0x04; (1MHz by setting FCRDIV to 2)
To reduce the bus clock more you can write the OUTDIV4 in SIM_CLKDIV1 with its highest value.

These changes are immediate any need no clock domain synchronisation.

pastedImage_1.png

To wake up from a low leakage mode after 60s you could look at using the RTC clocked from LPO. This allows all other clocks to be disabled and will wake up the processor once the programmed delay has elapsed. See also µTasker LLWU Support for some extra notes about low leakage wakeup modules.

Regards

Mark

Kinetis: µTasker Kinetis support

KL05: µTasker FRDM-KL05Z support

For the complete "out-of-the-box" Kinetis experience and faster time to market

684 Views
ky3orr
Contributor II

Hello Mark,

thank you for your comment.

Changing oscillator frequency live is really nice feature, but unfortunately I'd like to go into more power efficient mode where it stops.

Concerning LPO it is ok, but I can't rely on it as I'd like to wake device with precise timing.

I will do research to see if lowering frequency is sufficient.

As I understand systick is not operational in low leakage modes so I can't make use of calibrated high speed internal oscillator.

0 Kudos

684 Views
mjbcswitzerland
Specialist V

Grzegorz

The RTC allows a 1ms wakeup delay resolution to be programmed.

Its accuracy form LPO is however +/- 10% so will only give 60s +/- 6s in the worst case.

If you use a 32kHz crystal instead of IRCs you will have maximum accuracy

Regards

Mark

Kinetis: µTasker Kinetis support

KL05: µTasker FRDM-KL05Z support

For the complete "out-of-the-box" Kinetis experience and faster time to market


0 Kudos