[S32K396] eFlexPWM configuration issues MCU: S32K396 Driver: S32K3 RTD 7.0.1 Config tool: EB tresos Studio 30.0.0 Use case: 3-phase motor control (FOC), SM0..SM2 as complementary A/B pairs,20 kHz center-aligned PWM, fault handling on FAULT0 Question1: Pwm (FlexPWM): Fault settings are only available for the A output of a complementary channel pair — no way to configure the fault mapping of PWMB When a FlexPWM submodule is configured with Channel Pair = COMPLEMENTARY in the EB tresos Pwm plugin, only one channel entry (PWMA) is created and PWMB is automatically generated as the inverted output. However, in the fault settings (FlexPwmFaultChannelSettings: fault channel selection, fault level, fault output state, etc.) only the PWMA channel can be configured - there is no configuration entry for PWMB. The fault setup writes only the DIS0A field of SMx_DISMAP0. DIS0B and DIS0X keep their reset value 0xF and cannot be changed. Is there a supported way in EB tresos to configure the DIS0B/DIS0X mapping, or should this be considered a limitation/defect of the Pwm plugin? Question2: Pwm (FlexPWM): Center-aligned mode - no GUI option to generate an ADC trigger from a VAL0/VAL1 match (mid-point / reload trigger) (SM[x].TCTRL) We use center-aligned complementary PWM (SM0..SM2, 20 kHz) for 3-phase current sampling. In this configuration the center of the low-side conduction window coincides with the counter reload point, i.e. the VAL1 match. Sampling exactly at that instant gives the average phase current and maximum margin to the switching edges, which is the standard trigger point for low-side shunt FOC. In the EB tresos Pwm plugin, the per-channel Output Trigger configuration only offers "rising edge" / "falling edge" selections, which correspond to the VAL2/VAL3 match events. There is no option to enable the trigger sources tied to VAL0/VAL1 matches (TCTRL[OUT_TRIG_EN] bits for OUT_TRIG0/OUT_TRIG1 based on VAL0/VAL1), and no option tied to the reload event. Is there a supported way in this RTD release to generate an ADC trigger from the VAL0/VAL1 match (or from the reload event) in center-aligned mode? Questions3:Pwm (FlexPWM): Fault notification function configured in EB is generated as NULL_PTR in the PostBuild configuration In the EB tresos Pwm plugin, under FlexPwmFaultChannelSettings, a fault notification function name can be entered. The expectation is that the generated PostBuild configuration fills the callback member so that FlexPwm_Ip_Init() registers it into FlexPwm_Ip_aFaultIrqCallback[], and the fault ISR (FlexPwm_Ip_ProcessFaultIrq) calls it when FFLAG is set. But FlexPwm_Ip_VS_0_PBcfg.c generates the fault channel configuration with NULL_PTR. Is this a known limitation of the Pwm plugin, or a defect? Re: [S32K396] eFlexPWM configuration issues Hi,
Q1 – Fault mapping for complementary PWMA/PWMB
For a complementary channel pair, only PWMA is configured and PWMB is generated according to the configured A/B relationship.
The Pwm configuration provides individual fault enable settings through FlexPwmChannelFaultSettings. However, when complementary mode is selected, PWMB is no longer available as a separate configurable channel, so there is no corresponding GUI option to customize its DIS0B fault mapping.
With the default DISMAP reset configuration, the fault inputs remain enabled for the output. Therefore, from the application point of view, the required fault protection is preserved with the default configuration.
I will nevertheless check with the RTD team whether the inability to separately configure DIS0B/DIS0X in complementary mode is intentional and whether there is a supported method for applications requiring a different fault mapping.
Q2 – ADC trigger in center-aligned PWM mode
The Pwm configuration allows the trigger source to be selected from PWMX, PWMA or PWMB, together with rising edge, falling edge or both edge selection.
For center-aligned PWM, VAL1 determines the PWM period and therefore cannot be freely adjusted to move the ADC sampling point.
There are several possibilities depending on the required sampling point:
If sampling exactly at the PWM reload point is required, the FlexPWM reload pulse is directly available as a TRGMUX trigger source and can be routed through TRGMUX to BCTU/ADC.
If local synchronization using PWMX and its VAL0/VAL1 resources is not required for the submodule, PWMX can be configured and used for ADC triggering through the standard Pwm trigger configuration.
If the sampling point needs to be independently adjusted relative to the PWM center, a free VALx comparator can be configured through the FlexPWM IP APIs and used as an output trigger.
Therefore, the preferred solution depends on whether the ADC sampling point needs to be fixed at the PWM reload point or independently adjustable relative to it.
Q3 – Fault notification generated as NULL_PTR
According to the Pwm User Manual, FlexPwmFaultNotification specifies the user callback function for fault detection, and a configured value different from NULL or NULL_PTR should be used as the callback function name.
I also tested this with RTD 7.0.1 using the S32 Design Studio configuration tool. In this case, the configured fault notification is correctly propagated into FlexPwm_Ip_VS_0_PBcfg.c, including the callback prototype and the corresponding entry in the FaultNotification[] array.
However, I have not yet verified the same configuration using EB tresos Studio 30.0.0. Therefore, I will check with the RTD team whether there is any known difference or limitation in the EB tresos generation path that could result in NULL_PTR being generated instead.
BR, Petr 回复: [S32K396] eFlexPWM configuration issues I have also further questions as bellow: Q1.I would like to follow up on this statement: "With the default DISMAP reset configuration, the fault inputs remain enabled for the output. Therefore, from the application point of view, the required fault protection is preserved with the default configuration." This holds only if all four fault inputs are actually routed on the board. In our ECU only FAULT0 is connected (it carries the FS_FLAG of the gate driver, ST L9908). FAULT1..FAULT3 are not routed at all, so those pads are left floating / not configured as Port pins, and the IMCR does not route them - the fault inputs read a constant level. Since DISMAP0 resets to 0xFFFF (every fault input mapped to every output), the consequence is: --With FLVL = LOW for the unrouted channels, the constant low level is interpreted as a permanent fault and the outputs stay disabled forever. - With FLVL = HIGH for the unrouted channels, those fault channels are permanently inactive, but they are still mapped onto the A/B/X outputs. Therefore, we have to manually update the DISMAP0 register after 'Pwm_Init()', so that only FAULT0 is mapped to DIS0A / DIS0B / DIS0X. Whether the DIS0A/DIS0B/DIS0X fields can be exposed in the GUI for complementary mode (so that A and B can be mapped independently)? Q2. option1(FlexPWM reload pulse as a TRGMUX trigger source): We confirmed that TRGMUX_IP_INPUT_PWM0_MST_RELOAD is available. option2(PWMX for ADC triggering): This is actually the path we tried first, before opening this thread: we wanted a PWMX falling edge aligned to VAL1. But when Channel Pair = COMPLEMENTARY is selected, the EB tresos Pwm plugin does not allow creating a PWMX channel container for that submodule at all, so the trigger source PWMX cannot be selected. Could you confirm whether this restriction in the plugin is intentional, and whether PWMX-based triggering is supposed to be usable in complementary mode? If it is a plugin limitation, it would be worth reporting to the EB plugin team as well. Thanks again for the detailed answer. Re: [S32K396] eFlexPWM configuration issues Thank you for your response, and wait for your confirmation from RTD team.
View full article