How to get the imx6 epit clock frequency

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

How to get the imx6 epit clock frequency

430 Views
864535720
Contributor II

Hello everyone
The board I use is the development board of the IMX6Q of NXP official website. The kernel version I am using is linux3.14.52. The problem I am having now is: I want to get the clock frequency of the EPIT, I want to calculate the time period of its counting according to its frequency. Currently, my epit timer 1 and epit timer 2 are working properly. But when I get the clock frequency of the timer, the value I get is 0. The way I get it is:

struct clk *timer_clk = NULL;
  timer_clk = clk_get_sys("imx-epit.1", "per");
     If (IS_ERR(timer_clk))
     {
         Printk("Get EPIT1 time_clk fail !\n");
         Return -1;
     }
     clk_value = clk_get_rate(timer_clk);
     Printk("epit1 timer_clk->rate = %d !kernel \n", clk_value);

The last print is: epit1 timer_clk->rate = 0 !kernel

How can I get the actual frequency of the clock?
Because I want to use epit to achieve precise timing.
For example, I want to interrupt once in 1ms. What should I set the EPITLR register to be correct? At the same time, I hope to have a calculation method!
I look forward to your help.
thank you very much.

Labels (1)
0 Kudos
1 Reply

315 Views
art
NXP Employee
NXP Employee

The EPIT module has 3 possible reference clock sources.

1. Peripheral IPG_CLK_ROOT clock (typical frequency is 66MHz).

2. Peripheral reference PERCLK_CLK_ROOT clock (typical frequency is also 66MHz but can be downscaled with additional 6-bit divider).

For details about the clocks above, please check the CCM clock tree diagram in the Chapter 18 "Clock Controller Module (CCM)" (Page 794) of the i.MX6Dual/Quad Reference Manual Rev.5 document, available on the processor's Documentation web page:

https://www.nxp.com/products/processors-and-microcontrollers/arm-based-processors-and-mcus/i.mx-appl...

3. 32kHz clock source.

One of the reference clock sources above can be selected by appropriately setting the EPITx_CR[CLKSRC] register field. For details, please refer to the Sections 24.6.1 "Control register (EPITx_CR)" and 24.5.1 "Change of Clock Source" of the document above.

Then, there are the 12-bit clock prescaler and 32-bit counter register within the EPIT module.

So, to generate an interrupt every 1ms, you can, for example, select one of the 66MHz reference clock sources (see above), set the prescaler value to 66 (decimal) and counter value to 1000 (decimal).


Have a great day,
Artur

-------------------------------------------------------------------------------
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