How to find out what clock is used for timer

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

How to find out what clock is used for timer

1,277 次查看
qingg
Contributor I

Hi,

I am working on a project using example trgmux_lptmr_trigger_lpit as a starting point. I have a question about how I know what timer is set in the code. Specifically, in this example, the following code exists:

/* Get source clock for LPTMR driver */
#define LPTMR_SOURCE_CLOCK CLOCK_GetFreq(kCLOCK_LpoClk)
/* Define LPTMR microseconds counts value */
#define LPTMR_USEC_COUNT 500000U

...

/*
* Set timer period.
* Note : the parameter "ticks" of LPTMR_SetTimerPeriod should be equal or greater than 1.
*/
LPTMR_SetTimerPeriod(LPTMR0, USEC_TO_COUNT(LPTMR_USEC_COUNT, LPTMR_SOURCE_CLOCK));

How do I know kCLOCK_LpoClk is the clock I should pick for the macro but not any other clock? I assumes this means kCLOCK_LpoClk is set by the code somewhere but I couldn't find where.

Can anyone help?

 

Thanks,

Qing

标签 (1)
0 项奖励
回复
4 回复数

1,265 次查看
igorpadykov
NXP Employee
NXP Employee

Hi Qing

 

for clock sources for various modules one can look at Chapter 24 Clocking

i.MX7ULPRMB2: i.MX 7ULP Applications Processor Reference Manual for Silicon Revision B2

and in SDK files ../drivers/fsl_clock.h, fsl_clock.c

 

Best regards
igor

0 项奖励
回复

1,226 次查看
qingg
Contributor I

Let me try to rephrase the question:

I'm setting up a timer using the following commands:

LPTMR_GetDefaultConfig(&lptmrConfig);
lptmrConfig.prescalerClockSource = kLPTMR_PrescalerClock_0;

Now I want to get the frequency to generate an interrupt that is called every 1 ms. I plan to use the following command:

LPTMR_SetTimerPeriod(LPTMR0, USEC_TO_COUNT(1000U, CLOCK_GetFreq(XXX)));

What should I be replacing XXX with to get the desired performance for the clock I selected above?

0 项奖励
回复

1,213 次查看
igorpadykov
NXP Employee
NXP Employee

from team:

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

kCLOCK_LpoClk is defined in fsl_clock.h file.

There are 4 optional clock sources for LPTMR as following (from 7ULP reference manual):

 

lptmr-clk.png

You can choose one of the clock source here and then find the related clock name from clock_name_t struct in fsl_clock.h file.

Besides, you may need a 7ULP reference manual doc for more details:

i.MX7ULPRMB2: i.MX 7ULP Applications Processor Reference Manual for Silicon Revision B2

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

 

Best regards
igor

0 项奖励
回复

1,180 次查看
qingg
Contributor I

OK. Based on your explanations, I determined the answer is kCLOCK_ScgSircClk for the XXX in my code. In other words:

 

 

LPTMR_SetTimerPeriod(LPTMR0, USEC_TO_COUNT(1000U, CLOCK_GetFreq(kCLOCK_ScgSircClk)));

 

 

Thanks,

Qing

0 项奖励
回复