What is the frequency range for external clock inputs for KL02?

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

What is the frequency range for external clock inputs for KL02?

1,200 Views
timjones22
Contributor I

I need a controller with a clock accuracy better than what the internal clocks can deliver so I need to connect an external clock signal.

  • What is the frequency range of an external clock at EXTAL0?
  • I am currently using a FRDM evaluation kit. Is there any example code available, how to set the KL02 up to run on the higher frequency. I understand that default settings are using the external 32.768kHz crystal in conjunction with the internal clock generator

Thanks in advance, Tim

0 Kudos
6 Replies

936 Views
timjones22
Contributor I

Found it. Just realised that I have to alter MOD to set different frequencies.

0 Kudos

936 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Tim,

The TPM period when using up counting is (MOD + 0x0001) × period of the TPM counter clock.

Example of the output compare mode when the match toggles the channel.png

Best Regards,

Robin

0 Kudos

936 Views
timjones22
Contributor I

I see. Because the lptmr's time base can be between 900 and 1100us, I see those variances in my clock. It's actually quite a bit, up to 10% error.

However, I need something more accurate so I am planning to use one of the TPMs to generate a periodic time base, ideally a 1ms interrupt. If I use the 47.972352MHz system clock and set a TPM to output-compare mode with a compare value of 47972, I would expect to get about a 1ms time base.

Here's my problem: I started by using the output-compare driver example. Compare value is set to 0x1000 and I see a 366Hz signal at the output. But when I change that compare value, the output frequency stays the same.
What am I doing wrong here?

Thanks again!

0 Kudos

936 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Tim,

If you want to set KL02 run on the higher frequency (such as below red clock route), the frequency range of an external clock at EXTAL0 should meet the "ffll_ref FLL reference frequency range" in KL02P32M48SF0.pdf.

Clocking diagram.png

FLL reference frequency range.png

Example code can be found after download SDK_2.0_MKL02Z32xxx4 package( for example: ...\SDK_2.0_MKL02Z32xxx4\boards\frdmkl02z\driver_examples\mcg)

driver_examples.png

Select Configuration.png

Build SDK Package and download.png

You need read the "Kinetis SDK API Reference Manual MKL02Z4_v2.0.0.pdf".( It's in ...\SDK_2.0_MKL02Z32xxx4\docs folder.)

If you have never used Kinetis SDK2.0, "Getting Started with Kinetis SDK (KSDK) v.2.0.pdf" is recommand read first.

Best Regards,

Robin

0 Kudos

936 Views
timjones22
Contributor I

Thanks, that explains it. Did a bit more reading in the meantime and hope to have a slightly better understanding by now.

I was actually thinking of something like using a 24-48MHz oscillator at Extal0 and routing it straight through with MCGOUTCLK.

From what I read out of the SDK examples, they are all using the external 32.768kHz as clock source and generating a 47.972352MHz system clock, correct?

Unfortunately, my initial problem still exists: when I am running LPTMR driver example the time is not exactly 1s but about 1.0007s. Which is no real issue on a 1s timebase. But when I switched to 1ms by changing LPTMR_USEC_COUNT to 1000[us], the time base was 1.7ms, which is far out of range.

Looks like I got something wrong with the IRQ rather then system clock?

0 Kudos

936 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Tim,

1. I think you can using a 24-48MHz oscillator at Extal0 and routing it straight through with MCGOUTCLK.(such as below red clock route)

Figure 5-1. Clocking diagram.png

External reference.png

2. correct

Clock.png

OUTDIV1 SIM_CLKDIV1.png

3. It is not caused by system clock, this example use 1kHz LPO as clock source of LPTMR. You need set the LPTMRx_CMR=0x00 to get a 1ms IRQ. Please try to change LPTMR_USEC_COUNT=999, or use LPTMR_SetTimerPeriod(LPTMR0,0);

LPTMRx_CMR.png

LPTMR_USEC_COUNT.png

Observe the waveform on LED_Red (Pin7 J8 FRDM-KL02Z). The example toggle that pin in LPTMR_LED_HANDLER().

Best Regards,

Robin

0 Kudos