iMX8MM, Cortex-M4, PWM: calculate the clock frequency

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

iMX8MM, Cortex-M4, PWM: calculate the clock frequency

跳至解决方案
1,033 次查看
Raal
Contributor III

Hello,

I want to calculate the PWM clock frequency by Cortex-M4. Current setup is with SDK default values which is 32kHz clock frequency which I also verified by measurement.

I read out the PWM clock frequency with

CLOCK_GetClockRootFreq(kCLOCK_Pwm1ClkRoot)

which gives me 24MHz. This function also seems to take the pre/post dividers into account. Now I'm a bit confused because according to the clock tree figure on reference manual rev.3, page 315 there's no 32k clock source which can be assigned to PWM blocks by multiplexer.

What is the correct procedure to calculate the clock frequency with SDK functions?

Regards

0 项奖励
回复
1 解答
948 次查看
JorgeCas
NXP TechSupport
NXP TechSupport

Got it, I was using this as reference. 

But it is better to use this reference manual (2.14), this information matches to this case. 

Jorge7u7_0-1691089463806.png

As you said, there is no direct 32K clock source which can be assigned to PWM blocks by multiplexer, but some of the clock sources comes from the clock control module.

And according to fsl_pwm.h, these are the definitions to the clock sources:

Jorge7u7_1-1691089470322.png

Best regards.

在原帖中查看解决方案

0 项奖励
回复
6 回复数
974 次查看
JorgeCas
NXP TechSupport
NXP TechSupport

Hello,

According to the SDK reference manual the PWM clock sources could be:

Jorge7u7_0-1691022452093.png

Best regards.

0 项奖励
回复
963 次查看
Raal
Contributor III

Hello @JorgeCas 

this is interesting - my SDK manual shows the following:

Raal_0-1691038264487.png
Raal_1-1691038280588.png

This also fits to the device reference manual:

Raal_2-1691038364124.png

Your SDK information doesn't mention the 32kHz frequency? Which SDK version are you using?

Regards

0 项奖励
回复
949 次查看
JorgeCas
NXP TechSupport
NXP TechSupport

Got it, I was using this as reference. 

But it is better to use this reference manual (2.14), this information matches to this case. 

Jorge7u7_0-1691089463806.png

As you said, there is no direct 32K clock source which can be assigned to PWM blocks by multiplexer, but some of the clock sources comes from the clock control module.

And according to fsl_pwm.h, these are the definitions to the clock sources:

Jorge7u7_1-1691089470322.png

Best regards.

0 项奖励
回复
936 次查看
Raal
Contributor III

Hello @JorgeCas 

okay, thank you. I'll have to dig deeper into it to fully understand how peripheral clocking works.

Regards

0 项奖励
回复
998 次查看
JorgeCas
NXP TechSupport
NXP TechSupport

Hello,

The clock source for PWM can be configured with kPWM_LowFrequencyClock that corresponds to 32.768 KHz.

But it seems that the function is returning the value of the bus clock.

I suggest you check the value of struct pwm_config_t on clockSource to check the clock source for the counter.

Best regards.

0 项奖励
回复
985 次查看
Raal
Contributor III

Hello @JorgeCas 

okay, I'll check the PWM configuration. But how is the relation between clock tree and the clock source from PWM configuration register? It looks like the PWM clock mechanism works "around" the clock tree?

So, ClkSrc = 0x03 uses a dedicated 32.768 Hz clock which is not part of the clock tree? And 0x01/0x02 are sourced from clock tree?

Regards

0 项奖励
回复