s32k312 - Measure the pwm pulse using eMIOS

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

s32k312 - Measure the pwm pulse using eMIOS

1,852 Views
CCY_Yu
Contributor I

S32K312 with non-AutoSAR project

The current configuration is using PTC11 (EIRQ_19)to detect the edge.

And now we want to using PTA12 to generated the pwm pulse and using PTC11 to measure the duty cycle and period from PTA12. 

The previous configuration could generated the pwm pulse, however, after added the Emios_lcu module with call the API (Emios_Icu_Ip_Init(INSTANCE_1, &eMios_Icu_Ip_1_Config_PB_BOARD_INITPERIPHERALS);
, pwm pulse was disappeared.

1.The PTC11 was configured within SIUL2 LCU module, should i remove the configuration if we want to use Emios_lcu?
remove the channel configuration and HW interrupt list

CCY_Yu_2-1745464386813.png

 

CCY_Yu_1-1745464303089.png


2.Can you help to check if my configuration is correct or not?

  CCY_Yu_3-1745464457222.pngCCY_Yu_4-1745464476309.pngCCY_Yu_5-1745464497747.png

Remarks:

OPWM
PTA12/GPIO[12]/EMIOS_0_CH[14]_H

IPWM/SAIC
PTC11/GPIO[75]/EMIOS_1_CH[1]_H/EIRQ[19]

0 Kudos
Reply
3 Replies

1,724 Views
CCY_Yu
Contributor I

I am currently working with the eMIOS module and encountered some configuration questions. Could you kindly assist in clarifying the following points?

1. Clock Divider Value and Its Impact on ICU
In the provided sample code, the Clock Divider Value under EmiosCommon_0 is set to 200.
Could you please advise how the Clock Divider Value should be considered when configuring the ICU (Input Capture Unit)?
Specifically, how does it impact the measurement accuracy or behavior?

2. Channel Consistency Between ICU Measurement and PWM Signal
When using ICU_MODE_SIGNAL_MEASUREMENT (e.g., emios_0_ch_1_g) in IPWM mode for signal measurement,
is it necessary for the eMIOS channel to be the same as the PWM signal's channel (e.g., emios_1_ch_0_x)?
Or can the measurement channel be different from the PWM signal source channel?

My current RTD configuration is as follows:

PTA12 → eMIOS Channel 8

PTC11 → eMIOS Channel 0

3. Configuration Limitation in Emios_Icu
While configuring the Emios_Icu module in IcueMios, I noticed that only the "EMIOS_ICU_BUS_DIVERSE" option is available.
Could you please help identify the possible reasons for this limitation, and how to configure it to support other bus types if needed?

4. Measurement Accuracy with Varying PWM Signals
If the PWM signal has a period of 1Hz (1-second period) and a duty cycle of 5%,
would using ICU_MODE_SIGNAL_MEASUREMENT mode (e.g., emios_0_ch_1_g) still allow accurate capture of the signal's active time and period,
especially when the PWM frequency varies between 1Hz to 5Hz or the duty cycle varies from 0% to 100%?

0 Kudos
Reply

1,706 Views
_Leo_
NXP TechSupport
NXP TechSupport

Hi again,

Regarding your questions:

1. In the attached project goal is measure period of 10-600 Hz PWM signals.

So, considering max ticks for eMIOS are 65,534 (16 bits)…

For generate a PWM signal 8-600 Hz we will use a Global Prescaler = 250:

1s -> 120MHz/250 (480,000 ticks)
8Hz = (1/8)s
-> 480,000 *(1/600) = 60,000 ticks

10Hz -> 480,000 *(1/10) = 48,000 ticks

600Hz -> 480,000 *(1/600) = 800 ticks

For measure a PWM signal of 10-600 Hz with eMIOS clock frequency of 120MHz and using Global Prescaler = 200 (in Emios_Mcl_Ip driver):

1s -> 120MHz/200 (600,000 ticks)
10Hz = (1/10)s
-> 600,000 *(1/10) = 60,000 ticks

600Hz -> 600,000 *(1/600) = 1,000 ticks

Overflow (theoretically) should happen at -> 600,000/65,534 = 9.1556 Hz, But due to hardware implementation, the Icu Overflow Notification is out of sync with the event for ICU_MODE_SIGNAL_MEASUREMENT, ICU_MODE_TIMESTAMP and ICU_MODE_SIGNAL_EDGE_DETECT modes.

2. Please refer to Table 401. eMIOS channel types of reference manual in order to see which modes support each channel.

3. Please refer to Figure 321. EMIOS channel types, Figure 322. Block diagram and/or Table 403. Counter buses, channels, and timebase sources in order to see counter buses capabilities. EMIOS_ICU_BUS_DIVERSE refers to buses B, C or D.

4. Depending of PWM frequency that you will measure, you should set the Global Prescaler in order to take advantage of the entire counter. For example:

If you need to measure 10Hz and setting Global Prescaler = 200 (as attached example).

1s -> 120MHz/200 (600,000 ticks)
10Hz = (1/10)s
-> 600,000 *(1/10) = 60,000 ticks (very close to the max ticks 65,534).

Then you have 60,000 ticks for duty cycle resolution. Same math for PWM generation.

Hope it helps you.

If you have more questions, please help us creating a new post.

Have a nice day!

0 Kudos
Reply

1,779 Views
_Leo_
NXP TechSupport
NXP TechSupport

Thanks for contacting our technical support.

Yes! If you want to configure PTC11 as eMIOS, you should delete configuration EIRQ_19.

For period and duty cycle measurement please refer to attached project.

Such project perform IPWM mode using ICU_MODE_SIGNAL_MEASUREMENT (emios_0_ch_1_g) to get active time and period from a generated PWM signal (emios_1_ch_0_x).

Please use S32DS 3.6 and RTD 5.0.0 with S32K31XEVB-Q100 (and connect PWM to ICU pins). If you need different S32K3 derivative and/or RTD version, you can create a new project, do manual config and code copy.

Hope it helps you.

Have a nice day!

0 Kudos
Reply