Hello, we encountered a strange phenomenon while using the PWM output function with the s32k312. When configuring the clock divider value at the EMIOS_MCL layer for global frequency division, we found it did not work, but configuring the channel frequency divider was effective. For example, when the system clock frequency is 120MHz, if we set the global frequency division to 120 and the channel frequency division to 10, with a period tick of 50,000, the output frequency is 240Hz. However, if we set the global frequency division to 1 and the channel frequency division to 10, with the same period tick of 50,000, the output frequency remains 240Hz.
Solved! Go to Solution.
In your project, you didn't enable UCPREN bit.
eMIOS_Cn.UCPREN = 0:
eMIOS_Cn.UCPREN = 1:
Hi@fengba_360
"However, if we set the global frequency division to 1 and the channel frequency division to 10, with the same period tick of 50,000, the output frequency remains 240Hz"
I think this is wrong. It should still change. You can test it again.
Moreover, didn't you say that if the internal counter is selected for PWM output, it is unrelated to the MCL global prescaler?
I have tested it, and for PWM output, the global prescaler does not take effect, but it does take effect when measuring with PWM ICU.
Hi@fengba_360
This is impossible. I tested it and found that the global prescaler is effective for all channels.
My understanding is the same as yours, but the actual test result shows that the global division has not taken effect.
Hello, I have conducted another round of actual measurements, and here are my results. I set the global frequency division to 10 and the channel frequency division to 12. Based on theoretical calculations, the final frequency of this channel should be 1MHZ, with a tick of 50,000, resulting in an output frequency of 20HZ. However, when I measured it with an oscilloscope, the actual output frequency was 200HZ.
Hi@fengba_360
Did you initialize MCL in the main function?
It didn't work.
Please provide your project and I will check it for you.
My test project is in line with expectations.
Should I create a new case or directly send it to your email?
Hi@fengba_360
you can create a new case and tell me the case number.
hello :Please have a look.
In your project, you didn't enable UCPREN bit.
eMIOS_Cn.UCPREN = 0:
eMIOS_Cn.UCPREN = 1:
thanks,it is work
Emios_Mcl_Ip_Init(0U, &Emios_Mcl_Ip_0_Config);
Emios_Mcl_Ip_ConfigureGlobalTimebase(0U, TRUE);
Received, thank you. However, when I use the EMIOS ICU to measure PWM input and select the EMIOS_ICU_BUS_INTERNAL_COUNTER, the global frequency divider does indeed take effect. As shown in the figure below, I am somewhat confused. Could you please help clarify this?