s32k312 pwm period & icu configuration Hello, I am currently working with the PWM input and capture functions of the s32k312, and I have a few questions I would like to confirm with you: Regarding the calculation of PWM output frequency: Is the formula used as follows to determine the frequency? Frequency = core_clk / (master bus prescaler) / (clock prescaler) / tick For example: Frequency = 120MHZ / 1 / 12 / 5000 = 200HZ When capturing PWM period and duty cycle through the ICU, does the ICU start capturing immediately after initialization, and is there a running cycle for this process? Re: s32k312 pwm period & icu configuration Emios_Pwm_Ip_SetDutyCycle is different from Pwm_SetDutyCycle. Your understanding is suitable for Pwm_SetDutyCycle: 0x0000 means 0% 0x8000 means 100%
But the duty cycle of Emios_Pwm_Ip_SetDutyCycle is calculated as follows: NewDutyCycle/Period[ticks] 3276/50000=6.55% 6553/20000=32.765% It matches your test results. Re: s32k312 pwm period & icu configuration Alright, I understand. I'm currently testing, thank you. Additionally, I have one more question regarding the duty cycle. I'm not sure if my calculations are correct, so I would appreciate your guidance. I'm currently using the function Emios_Pwm_Ip_SetDutyCycle(uint8 Instance, uint8 Channel, Emios_Pwm_Ip_DutyType NewDutyCycle) to set the duty cycle: When I set the frequency to 200Hz and pass NewDutyCycle=3276.8, the duty cycle measured by the oscilloscope is not 10% but 6.5%. When I set the frequency to 500Hz and pass NewDutyCycle=6553.6, the duty cycle is not 20% but 32%. Can you please tell me where my configuration might be incorrect?" Re: s32k312 pwm period & icu configuration Hi
Seems that emios is configured as OPWFMB mode. Clock Divider Value in Emios_Mcl_Ip is used to calculate PWM frequency.
Frequency = core_clk / (Clock Divider Value) / (clock prescaler) / tick
Please verify it by testing.
Please refer to the S32K344_Example_Emios_Icu_IPWM_measurement_DS34_RTD_100_v2 :
/*Start measuring */
Emios_Icu_Ip_StartSignalMeasurement(EMIOS1, EMIOS_ch1);
Emios_Icu_Ip_GetInputState(EMIOS1, EMIOS_ch1);
/* Get captured duty-cycle and period*/
Emios_Icu_Ip_GetDutyCycleValues(EMIOS1, EMIOS_ch1, &ic_result_temp);
/* If captured */
if(ic_result_temp.PeriodTime)
{
/* Stop measuring */
Emios_Icu_Ip_StopSignalMeasurement(EMIOS1, EMIOS_ch1);
captured = 1;
}
Best Regards, Robin ------------------------------------------------------------------------------- Note: - If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored Please open a new thread and refer to the closed one, if you have a related question at a later point in time. -------------------------------------------------------------------------------
記事全体を表示