What is the formula for Calculation of Frequency when using FTM peripheral in EPWM mode using S32K144.
I have configured by FTM Peripheral via System clock and after dividing it by prescaler 8. My FTM peripheral input clock is of: 1Mhz.
Now what is the formula for calculation of Frequency?
Like in Datasheet, it is mentioned, as shown in below figure.
What is the units of EPWM period is it secs or us??
Also if I am using EPWM mode, in which I have set counter period (ticks)= 2: Which is MOD register value and duty cycle(ticks) = 1: which is CnV register value.
On checking the signals on Logic Analyzer, frequency which comes out is of : 3Mhz. How is this calculated??? Duty cycle is fine. 50 percent am expecting. But how is 3Mhz frequency calculated.
Solved! Go to Solution.
Okay, got the issue solved. My FTM Clock source was selected system clock and i was doing calculations with FTM Input clock
Okay, got the issue solved. My FTM Clock source was selected system clock and i was doing calculations with FTM Input clock
Hi @gkunalupta,
You can refer to both AN5413: S32K1xx Series Cookbook and AN5303: Features and Operation Modes of FlexTimer Module on S32K application notes. The cookbook configures the Edge-Aligned Pulse Width Modulation (EPWM): 1 Hz, low 25%, high 75%, with the input clock source to 8 MHz.
The edge-align PWM period is determined by the clock source. For example, prescale clock source by 128 (8 MHz / 128 = 62500 Hz), counter count up value is 62500 = 1 second period.
You can also measure the value for the PWM period, as shown in this community post: Solved: How to calculate the duty cycle and frequency of PWM wave based on SDK - NXP Community.
Best regards,
Julián
I read the above application notes that u mentioned. What I can get from those notes, is that
FTM Period for EPWM mode is = ((MOD - CNTIN) +0x1) counter ticks.
I tried the same configurations as well that are mentioned in application note:
FTM clock after prescaler: 8Mhz/128= 62500Hz
Meaning:
1 FTM Counter tick = 1/FTM Clock after prescale = 1/62500Hz = 16us.
That is each increment of counter will take 16us.
Now setting the, MOD values as stated in application notes
MOD= 62499 and CNTIN =0.
So FTM Period = ((MOD - CNTIN) +0x1) = 62500 counter ticks
Meaning, FTM Period = 62500*16 us = 1 sec
& FTM Frequency = 1hertz
This is what is stated in application note also.
But when I run my code and see it on logic analyzer, the Frequency I am getting is of 6 hertz.
Why is it so??
Is there some formula error or what??
I tried various values as per the calculations/formulas stated in application notes and reference manual. But when i do on S32K144, the signals are observed of different values that are expected.
What i want to achieve is to generate different frequencies from 200Khz to 10 Mhz. For that i want to understand this EPWM frequency calculation part
FTM clock after prescale: 8Mhz/128= 62500Hz
1 Counter tick = 1/FTM Clock after prescale = 1/62500Hz = 16us
MOD= 62499 and CNTIN =0 Hz
So FTM Period = ((MOD - CNTIN) +0x1) = 62500 counter ticks
Meaning, FTM Period = 62500*16 us = 1 sec
FTM clock after prescale: 8Mhz/1 = 8Mhz
1 Counter tick = 1/8Mhz = 0.125us
MOD= 62499 and CNTIN =0 Hz
So FTM Period = ((MOD - CNTIN) +0x1) = 62500 counter ticks
Meaning, FTM Period = 62500*.125 us = 7812.5 us