I'm using the eFlexPWM module (instance IP_EFLEXPWM_0) on an S32K364 microcontroller to measure the frequency and period of an external signal via input capture. I am using submodule 2 (SM[2]). My configuration is as follows:
SM2_CAPTCTRLB->EDGB0 = 0x02; (capture on rising edge for capture circuit 0)
SM2_CAPTCTRLB->EDGB1 = 0x02; (capture on rising edge for capture circuit 1)
SM2_ARMB = 1; (arm the capture circuits)
After running the code, I observe the following:
In SM2_CAPTCTRLB, the counter status bits show:
CB0CNT = 0x4
CB1CNT = 0x4
In SM2_STS, both flag bits are set:
CFB0 = 1
CFB1 = 1
However, the captured values (SM2_CAPTCOMPB) remain 0 for both capture circuits – no data is latched.
What could be causing this? Is there any additional configuration needed (e.g., clock enable, input muxing, or counter setup) that I might have missed? The flags indicate that capture events are detected, but the captured values are not updated. Any insight would be greatly appreciated.
Feel free to add any additional details (like your pin muxing settings or counter mode) if needed. Good luck!
Hi
First, I checked the latest S32K3 RTD 7.0.x; however, the S32 Configuration Tool does not yet support the eFlexPWM E-Capture functionality.
If it is convenient, could you share your project so I can test it on the S32K396? (Unfortunately, I don’t have the S32K364; I only have the S32K396-BGA-DC1 evaluation board.)
Secondly, please review section “56.3.14 Enhanced capture (E-Capture)” in S32K396RM (Rev. 4, 11/2024). Please check the registers mentioned in that section, especially those in Figure 254. E-Capture logic. You can also share screenshots of the eFlexPWM_0 registers with me.
In addition, if you want to read the value of SM2_CAPTCOMPB[EDGCNTB], please first enable SM2_CAPTCTRLB[EDGCNTB_EN] and SM2_CAPTCOMPB[EDGCMPB].
I’m not sure why you set SM2_CAPTCOMPB[EDGCMPB] to 0, as this seems to prevent the comparator in Figure 254. E-Capture logic from functioning correctly.
It appears that the period of submodule2 is too short. Please read "56.3.18.3 Running a submodule at a lower frequency than submodule 0" and try selecting a lower frequency clock source for submodule2, such as AUX_CLK or EXT_CLK.
Hi@Robin_Shen ,
I have successfully implemented external frequency measurement by properly configuring the MCTRL and CAPTCTRLB registers. However, testing shows the minimum measurable frequency I can achieve is 5 kHz, while my requirement is to support frequencies as low as 1 Hz.
I have attempted adjusting the Prescaler and PrescalerAlt configurations, yet no improvement was observed. Could you please share some suggestions and troubleshooting approaches? Thank you very much for your support.