MCU : s32k324
PIN : PTE10 (LED)
Inatnace : Emios0
Emios CH number : 20
Clock freq = 160 MHZ
i'm triying to configuration eMISO_PWM for 40% duty cycle of 1 second for that i want to know calculation formula and value of counter(tick), prescaler. base on above mention paramter.
and also shared Screenshot of configuration and code
Check the following thread, it has information related to the topic that may be useful to you.
BR, VaneB
hello @VaneB
thank you for resopnce
but i'm still confuse
my requirement is i want to generate 40% duty cycle of 1 second period. base on this equation PWM frequency = CORE_CLK / global prescaler / internal prescaler / (B1+1).
for that we below mention parameters
Emios Mcl (module)
1. Clock Divider value (global prescaler)
2. default period
3. Master bus prescaler
4. Master bus Alternate prescaler
Emios Pwm (module)
mode : EMIOS_PWM_IP_MODE_OPWMB
Clock prescaler
Clock prescaler Alternate
Duty cycle [tick]
period [tick]
please share configuration value for this parameter.
As you said, the EMIOS module setting in ConfigTools are named as Clock_Divider Value, Master_Bus Prescaler, and Master BusAlternate Prescaler. How to know their relationship and their usage according to the formula provided in the thread shared above?
PWM frequency = CORE_CLK / Clock Divider Value / Master Bus Prescaler / period [ticks]
With this information, if we want a PWM of 1KHz and the clock frequency of our eMIOS is 48Mhz and we define the Clock Divider Value and the Master Bus Prescaler equal to 1, with this we would only need one parameter to obtain our 1KHz signal, which is the period [tick] which we can obtain by solving the formula given above:
period [tick] = CORE_CLK/1KHz, giving 48,000.
To set the Duty cycle [tick] of this signal, we assume a duty cycle of 100% is equal to the period [tick](48000 ticks), so a duty cycle of 40% will be equal to a (period [tick]*40)/100 = 19,200 ticks approx.
Additionally, with a 16-bit timer the maximum number of tick (ticksmax) is (2^16 − 1) = 65,535 ticks. If we configure the eMIOS with a fClock of 48MHz (fClock = CORE_CLK / Clock Divider Value / Master Bus Prescaler) we have a tick every 1/(fClock ) = 1/48MHz = 0.02083μs approx (it depends on your configurations).