Hi All,
I am using S32K358 board and have configured 4 PWM Output Channel in OPWFMB mode with the same clock pre-scaler and configurable Period (Variable Period) for all the PWM output channels using EB tresos listed below:
EMIOS_0_CH_3 = MSCR 130 = GPIO 130 = PTE2
EMIOS_0_CH_1 = MSCR 45 = GPIO 45 = PTB13
EMIOS_0_CH_4 = MSCR 48 = GPIO 48 = PTB16
EMIOS_0_CH_2 = MSCR 46 = GPIO 46 = PTB14
Saw the below formula from one of the queries raised in community,
PWM frequency = CORE_CLK / global pre-scaler / internal pre-scaler / (B1+1)
"B1 is a value written to channel B register."
But as per this calculation, I was not getting the output frequency and is mismatching with the actual generated signal (verified its frequency through oscilloscope).
Below are the values that I set in PWM module:
CORE_CLK = 240MHz | OPWFMB Mode |
Global Pre-scaler: 44 (Clock Divider value set in MCL module - EMIOS0_CH23)
Internal Pre-scaler (Clock prescaler): 2
As per the formula, I got 340.8664Hz (240MHz/ (44*2*(8000+1)), but what I got from the oscilloscope was having 3.67kHz for 50% duty cycle. (Reg-A value: 4000h & Reg-B value: 8000h).
Kindly help me to understand, how the PWM frequency being calculated.
Thank you.
Solved! Go to Solution.
Hi,
Thank you so much for your interest in our products and for using our community.
The formula you found in the post is correct. What I can infer from your configuration is that the Prescaler Clock Source (UCPRECLK) should be set to EMIOS_PWM_IP_PS_SRC_PRESCALED_CLOCK so that the eMIOS channel clock is CORE_CLK divided by the Global Prescaler (GPRE).
Hope it helps you.
Have a nice day!
Hi, It worked after configuring the Prescaler Clock Source (UCPRECLK) to EMIOS_PWM_IP_PS_SRC_PRESCALED_CLOCK .
Thank you for your support.
Hi,
Thank you so much for your interest in our products and for using our community.
The formula you found in the post is correct. What I can infer from your configuration is that the Prescaler Clock Source (UCPRECLK) should be set to EMIOS_PWM_IP_PS_SRC_PRESCALED_CLOCK so that the eMIOS channel clock is CORE_CLK divided by the Global Prescaler (GPRE).
Hope it helps you.
Have a nice day!