Hello, I am using KV11Z and using the example ftm_simple_pwm. In the example, 24kHz can make the LED gradually brighter and darker. I want to output a 50Hz PWM modification signal.
So, I tried to change the frequency to 50Hz, but I didn't get any signal when I used the dialogue.
Want to know where is the problem?
thanks,
解決済! 解決策の投稿を見る。
Hi le27,
Peripherals tool can help know what is the suitable value of prescaler.
You shall get error by using kFTM_Prescale_Divide_1 of FTM_GetDefaultConfig. Please change the prescale :
config->prescale = kFTM_Prescale_Divide_32;
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.
-------------------------------------------------------------------------------
Hi le27,
Peripherals tool can help know what is the suitable value of prescaler.
You shall get error by using kFTM_Prescale_Divide_1 of FTM_GetDefaultConfig. Please change the prescale :
config->prescale = kFTM_Prescale_Divide_32;
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.
-------------------------------------------------------------------------------
Thank you for your reply and guidance. I followed the method and modified config->prescale = kFTM_Prescale_Divide_1 to config->prescale = kFTM_Prescale_Divide_32; directly in the file of fsl_ftm.c. It can be observed that the LED on the control board changes gradually according to the change of duty_cycle Bright and gradually dimming, there is no problem, and the PWM output signal with a frequency of 50 Hz can be reached through the oscilloscope.
Then try to add ftmInfo.prescale = kFTM_Prescale_Divide_32; to the file of ftm_simple_pwm. I want to set the prescale from this, but maintain config->prescale = kFTM_Prescale_Divide_1 in the fsl_ftm.c file; the execution result shows that no PWM signal is generated, which is not clear. Is there a mistake in the use of the program?
At present, i am also trying to modify the program to achieve a fixed frequency and adjustable duty cycle PWM output signal.
Thanks,
The arrow in my picture is a bit misleading.
Please put ftmInfo.prescale = kFTM_Prescale_Divide_32; between FTM_GetDefaultConfig and FTM_Init
Hi Robin
Now it is possible to generate a PWM signal, but encountered it again.
Set to 50Hz PWM frequency, it is only 71Hz from the observation.
I don't know why the 50Hz PWM signal is not generated. I think this is caused by the delay. I go to DELAY place to modify it. From the original 80,000 to 115400, the KV11Z development board can be generated from the file is a 10M crystal oscillator, calculate i=1 =0.1us, the direction is estimated to be 115400 by trial and error, and set the fixed duty cycle to 50%.
Finally, the required Hertz PWM signal and duty cycle can be obtained. But I still don't know if this is the correct way. I think it should only be necessary to adjust FTM_SetupPwm (BOARD_FTM_BASEADDR, &ftmParam, 1U, kFTM_CenterAlignedPwm, 50U, FTM_SOURCE_CLOCK); the PWM frequency value in this row can be used to obtain the desired PWM frequency.
I need help in this regard, thank you.
Do you ever check the results of "FTM_SetupPwm"? First off it has a number of asserts which may cause the application to hang without any kind of indication. Secondly, "FTM_SetupPwm" may return an error value but continue executing as if there wasn't a problem.
I believe the most likely error will be that FTM_SetupPwm is returning an error code because the calculation done by "FTM_SetupPwm" for 50Hz results in values which can't be generated by the hardware.
That's a very low speed - you're probably going to have to create your own PWM using a timer.
Good luck!
The program continues as you said, as if no error has occurred, and no signal is generated through the oscilloscope. This time, a problem that requires frequency setting prescale has been discovered.
Thank you for your blessing and reply.