s32k312 pwm output

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

s32k312 pwm output

跳至解决方案
1,838 次查看
fengba_360
Contributor III

Hello, we encountered a strange phenomenon while using the PWM output function with the s32k312. When configuring the clock divider value at the EMIOS_MCL layer for global frequency division, we found it did not work, but configuring the channel frequency divider was effective. For example, when the system clock frequency is 120MHz, if we set the global frequency division to 120 and the channel frequency division to 10, with a period tick of 50,000, the output frequency is 240Hz. However, if we set the global frequency division to 1 and the channel frequency division to 10, with the same period tick of 50,000, the output frequency remains 240Hz.

微信图片_20241220141610.png微信图片_20241220141615.png

0 项奖励
回复
1 解答
1,647 次查看
Senlent
NXP TechSupport
NXP TechSupport

Hi@fengba_360

In your project, you didn't enable UCPREN bit.

 

Senlent_1-1735020814969.png

eMIOS_Cn.UCPREN = 0:

Senlent_2-1735020835553.png

eMIOS_Cn.UCPREN = 1:

Senlent_3-1735020845523.png

 

在原帖中查看解决方案

0 项奖励
回复
18 回复数
1,773 次查看
Senlent
NXP TechSupport
NXP TechSupport

Hi@fengba_360

"However, if we set the global frequency division to 1 and the channel frequency division to 10, with the same period tick of 50,000, the output frequency remains 240Hz"

I think this is wrong. It should still change. You can test it again.

0 项奖励
回复
1,767 次查看
fengba_360
Contributor III

Moreover, didn't you say that if the internal counter is selected for PWM output, it is unrelated to the MCL global prescaler?

0 项奖励
回复
1,768 次查看
fengba_360
Contributor III

I have tested it, and for PWM output, the global prescaler does not take effect, but it does take effect when measuring with PWM ICU.

 

0 项奖励
回复
1,759 次查看
Senlent
NXP TechSupport
NXP TechSupport

Hi@fengba_360

This is impossible. I tested it and found that the global prescaler is effective for all channels.

Senlent_0-1734942787563.png

 

0 项奖励
回复
1,751 次查看
fengba_360
Contributor III

My understanding is the same as yours, but the actual test result shows that the global division has not taken effect.

0 项奖励
回复
1,754 次查看
fengba_360
Contributor III

Hello, I have conducted another round of actual measurements, and here are my results. I set the global frequency division to 10 and the channel frequency division to 12. Based on theoretical calculations, the final frequency of this channel should be 1MHZ, with a tick of 50,000, resulting in an output frequency of 20HZ. However, when I measured it with an oscilloscope, the actual output frequency was 200HZ.

1.png2.png3.jpg

0 项奖励
回复
1,748 次查看
Senlent
NXP TechSupport
NXP TechSupport

Hi@fengba_360

Did you initialize MCL in the main function?

0 项奖励
回复
1,703 次查看
fengba_360
Contributor III

It didn't work.

5.jpg6.png

0 项奖励
回复
1,690 次查看
Senlent
NXP TechSupport
NXP TechSupport

Hi@fengba_360

Please provide your project and I will check it for you.

My test project is in line with expectations.

0 项奖励
回复
1,686 次查看
fengba_360
Contributor III

Should I create a new case or directly send it to your email?

0 项奖励
回复
1,683 次查看
Senlent
NXP TechSupport
NXP TechSupport

Hi@fengba_360

you can create a new case and tell me the case number.

0 项奖励
回复
1,677 次查看
fengba_360
Contributor III
case:00674118
0 项奖励
回复
1,742 次查看
fengba_360
Contributor III

hello :Please have a look.

4.png

0 项奖励
回复
1,648 次查看
Senlent
NXP TechSupport
NXP TechSupport

Hi@fengba_360

In your project, you didn't enable UCPREN bit.

 

Senlent_1-1735020814969.png

eMIOS_Cn.UCPREN = 0:

Senlent_2-1735020835553.png

eMIOS_Cn.UCPREN = 1:

Senlent_3-1735020845523.png

 

0 项奖励
回复
1,602 次查看
fengba_360
Contributor III

thanks,it is work

0 项奖励
回复
1,737 次查看
Senlent
NXP TechSupport
NXP TechSupport

Hi@fengba_360

Emios_Mcl_Ip_Init(0U, &Emios_Mcl_Ip_0_Config);

Emios_Mcl_Ip_ConfigureGlobalTimebase(0U, TRUE);

 

0 项奖励
回复
1,830 次查看
Senlent
NXP TechSupport
NXP TechSupport

Hi@fengba_360

You select "Internal Counter" for Ch5, so there is nothing do to with "Mcl" settings.

Senlent_0-1734679968436.png

 

 

0 项奖励
回复
1,810 次查看
fengba_360
Contributor III

Received, thank you. However, when I use the EMIOS ICU to measure PWM input and select the EMIOS_ICU_BUS_INTERNAL_COUNTER, the global frequency divider does indeed take effect. As shown in the figure below, I am somewhat confused. Could you please help clarify this?

 

微信图片_20241220162912.png

 

0 项奖励
回复