PWM period

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

PWM period

Jump to solution
1,104 Views
Ajul
Contributor I

Hi

I was working on NXP s32k324 controller .

Need to run a PWM at 35Hz and 125Hz .

In S32k data sheet It is mentioned like The frequency range is b/w 400Hz to 20Khz . Is it possible to run the PWM at 35 and 125 Hz ? If yes could you please tell me How to achieve this.

 

Regards

Ajul

0 Kudos
Reply
1 Solution
1,092 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

yes, it is possible.
eMIOS module is clocked from CORE_CLK (up to 160Mhz). eMIOS divides this clock by the global prescaler (MCR[GPRE] + 1) and routes the resulting prescaled clock output to the channel internal prescaler (Cn[UCPRE] + 1). Thus channel internal counter counts (CORE_CLK/global prescaler/internal prescaler) clock. Channel offers also extended prescaler.
Channels Y/H do not have internal counters so must select some counter bus (global or local) which are be running from. The MCB mode is used to run on channels that serves as counter buses (ch 23,22,0,8,16).
Period in MCB mode is given as An[A]*global prescaler*internal prescaler/CORE_CLK.
Similar equation is also valid for modes generating PWM signal directly, like OPWFMB.
Global prescaler can range from 1 to 256. Internal prescaler can range from 1 to 4.
Register An is 24bit wide. So you can easily calculate longest PWM period for used Core clock, prescalers and An value.

BR, Petr

View solution in original post

0 Kudos
Reply
6 Replies
1,083 Views
Ajul
Contributor I

Hi,Petr

 

Can you please share the EB configuration for this ?

It would be help full for better understand

 

Regards

Ajul

0 Kudos
Reply
1,083 Views
Ajul
Contributor I

Hi

Right Now Iam using core clock (160MHz) as input to the PWM.

Ajul_0-1688125572942.png

 

 

0 Kudos
Reply
1,039 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

as module clock is selected then global prescaler has no effect for this channel and just local one is taken into account for this OPWFMB mode. So for 160MHz module clock and prescaler of 16, to have 35Hz generated use 285714 for Period setting.

BR, Petr

0 Kudos
Reply
1,027 Views
Ajul
Contributor I

Hi

How we can give period value as   285714 because the maximum value we can give is 65534 in the configuration.

 

Default period value of Pwm channel at initialization.
The measure unit are in ticks (if Period In Ticks checked), or in seconds (if unchecked)
Valid range: [0, 65534]
<note>

0 Kudos
Reply
1,021 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

yes, you are right, there is 16bit counter, 24bit counter is on different device.
Then you need to use global divider as well. As prescaler source select EMIOS_PWM_IP_PS_SRC_PRESCALED_CLOCK. Within MCL component you can configure eMIOS global divider. Then calculate period value for global and internal prescalers.

BR, Petr 

0 Kudos
Reply
1,093 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

yes, it is possible.
eMIOS module is clocked from CORE_CLK (up to 160Mhz). eMIOS divides this clock by the global prescaler (MCR[GPRE] + 1) and routes the resulting prescaled clock output to the channel internal prescaler (Cn[UCPRE] + 1). Thus channel internal counter counts (CORE_CLK/global prescaler/internal prescaler) clock. Channel offers also extended prescaler.
Channels Y/H do not have internal counters so must select some counter bus (global or local) which are be running from. The MCB mode is used to run on channels that serves as counter buses (ch 23,22,0,8,16).
Period in MCB mode is given as An[A]*global prescaler*internal prescaler/CORE_CLK.
Similar equation is also valid for modes generating PWM signal directly, like OPWFMB.
Global prescaler can range from 1 to 256. Internal prescaler can range from 1 to 4.
Register An is 24bit wide. So you can easily calculate longest PWM period for used Core clock, prescalers and An value.

BR, Petr

0 Kudos
Reply