How to measure CPU frequency of Kinetis devices in fast way?

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

How to measure CPU frequency of Kinetis devices in fast way?

1,880 Views
astrogreco
Contributor II

Goodmorning. I'm a software developer from SMH Technologies. We build an universal programmer for microcontrollers.
I need to program the internal memories of Kinetis devices, so I set and use the flash controller using ARM Debug Architecture with SWD protocol.
There are two types of flash controllers (called FTMRE and FTMRH) those require setting of the clock divisor FCLKDIV, which setting depends on the frequency of the flash controller has. This frequency is the BUS clock which is usually half of CPU frequency by default.
So I need to know the correct CPU frequency, to know the BUS frequency and hence to know the flash controller frequency.
The CPU frequency (in default state) depends on internal reference clock and FLL moltiplicator that is written in the reference manual.
The problem is some devices the internal reference clock in not defined as typical as we have a range of possible values and therefore a larget set of possible frequencies of CPU.
So it is necessary to measure it!

To create an universal routine for all kinetis I implemented a function that uses the ARM System Timer (because it is present in every Cortex-M).
The function works with this counter and I made a "for-cycle" to repeat the timer count many certain times and with the external tool in SWD protocol i measure the time. This works, but require too many seconds. (depends on the rated frequency and the allowed error).


I ask if there is a faster procedure to measure the CPU clock frequency through an external tool that owns the time sample. Maybe using the hardware of the ARM Cortex Architecture (Debug Monitor, Halt of the Core, Watchpoints, Breakpoints) and universal for every Kinetis (or Cortex-M).

I think it's an interesting question/topic.

 

In attachment the function I used.

Thank you
Best Regards.

0 Kudos
Reply
1 Reply

1,855 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi,

Please refer to the following community post by a colleague that explains some ways to verify internal clocks frequencies using Kinetis devices.

Verifying Internal Clocks in Kinetis - NXP Community

Hope it helps!

Regards,

Felipe

-------------------------------------------------------------------------------

Note:

- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored. Please open a new thread and refer to the closed one, if you have a related question at a later point in time.

------------------------------------------------------------------------------ 

0 Kudos
Reply