S32k312 EMIOS PWM output

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

S32k312 EMIOS PWM output

449 Views
Dev15
Contributor III

@Senlent ,

 

I'm trying to configure some PWM output signals in EMIOS 0 and EMIOS 1 instances to generate up t0 20KHz frequency.

S32 Design Studio for S32 Platform
Version: 3.5

S32k312 evaluation board

Below are my configurations screen shots for reference

Dev15_0-1722524228420.png

 

Dev15_1-1722524244431.png

 

Dev15_2-1722524269770.png

 

Dev15_3-1722524306547.png

 

Dev15_4-1722524318226.png

 

Currently, global clock for EMIOS 0 and 1 are 160 MHz.

For testing, I tried to generate 1000 Hz and 50 % duty cycle. The scope result is not as expected. Only duty cycle is correct and frequency is not correctly displayed.

 

#define PWM_CLOCK_FREQUENCY (120000000U)
#define PWM_PRESCALAR (3U)
#define PWM_DIV_FREQUENCY ((PWM_CLOCK_FREQUENCY/PWM_PRESCALAR))

pwm_Frequency = 1000U;
Pwm_Period[pwm_ChannelId] = (PWM_DIV_FREQUENCY/pwm_Frequency);
Pwm_DutyCycle[pwm_ChannelId] = ((Pwm_Period[pwm_ChannelId] * pwm_DutyCycle)/100);

Below API's are called in the code for frequency & duty cycle.

Emios_Pwm_Ip_SetPeriod(INSTANCE_0, Emios_Pwm_Ip_I0_Ch0.ChannelId, Pwm_au16Period[pwm_ChannelId]);
Emios_Pwm_Ip_SetDutyCycle(INSTANCE_0, Emios_Pwm_Ip_I0_Ch0.ChannelId, Pwm_DutyCycle[pwm_ChannelId]);

 

Also, what is the purpose of Emios_Mcl_Ip_SetCounterBusPeriod() API. Do we need to call one time on initialization or every time when new frequency and duty cycle are called.

Please let me know if anything configured incorrectly

 

Thank you,

 

Tags (1)
0 Kudos
Reply
2 Replies

369 Views
_Leo_
NXP TechSupport
NXP TechSupport

Hi,

Thank you so much for your interest in our products and for using our community.

For PWM_CLOCK_FREQUENCY (120000000U):
     1s -> 120MHz (120,000,000 ticks)
     1kHz = (1/1,000)s
     ->120,000,000 *(1/1,000) = 120,000 ticks
     But the max ticks is 65534.

What you can do is reduce PWM_CLOCK_FREQUENCY to archive lower PWM frequencies.

On the other hand S32K312 Examples are included in S32DS 3.4 with RTD 2.x.x. You can have multiple IDEs.

Hope it helps you.

Have a nice day!

0 Kudos
Reply

405 Views
Dev15
Contributor III

@Senlent ,

 

Any update on the above request please?

 

Thank you,

Tags (1)
0 Kudos
Reply