s32k312 pwm output

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

s32k312 pwm output

Jump to solution
1,227 Views
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 Kudos
Reply
1 Solution
1,036 Views
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

 

View solution in original post

0 Kudos
Reply
18 Replies
1,162 Views
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 Kudos
Reply
1,156 Views
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 Kudos
Reply
1,157 Views
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 Kudos
Reply
1,148 Views
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 Kudos
Reply
1,140 Views
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 Kudos
Reply
1,143 Views
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 Kudos
Reply
1,137 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@fengba_360

Did you initialize MCL in the main function?

0 Kudos
Reply
1,092 Views
fengba_360
Contributor III

It didn't work.

5.jpg6.png

0 Kudos
Reply
1,079 Views
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 Kudos
Reply
1,075 Views
fengba_360
Contributor III

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

0 Kudos
Reply
1,072 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@fengba_360

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

0 Kudos
Reply
1,066 Views
fengba_360
Contributor III
case:00674118
0 Kudos
Reply
1,131 Views
fengba_360
Contributor III

hello :Please have a look.

4.png

0 Kudos
Reply
1,037 Views
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 Kudos
Reply
991 Views
fengba_360
Contributor III

thanks,it is work

0 Kudos
Reply
1,126 Views
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 Kudos
Reply
1,219 Views
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 Kudos
Reply
1,199 Views
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 Kudos
Reply