I am using the MCUXpresso SDK_2.x_FRDM-K66F example for FTM output compare project: "frdmk66f_driver_examples_ftm_ftm_output_compare." The FTM output toggles as expected but when I change the FTM compare value, the timing does not change. I've stepped through the FTM_SetupOutputCompare library function. I'm running on the FRDM-K66F eval board.
Changing the compare value should change the frequency of the output, why doesn't this work?
Solved! Go to Solution.
Q: Are you suggesting that this function doesn't work as advertised?
A: No. The channel output is changed based on what is specified in the compareMode argument, but it's hard to observe when you has only one channel.(The CnV only move the waveform, it can not change the frequency. The frequency is related to MOD, you need to use FTM_SetTimerPeriod change the frequency.)
You may need to add another channel and only modify one of them. Then you can observe the waveform move.
Please use FTM_SetTimerPeriod function change the frequency of the output.
The compare value is not used to do that.
Best Regards,
Robin
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Robin,
Thanks for your reply. The SDK demo program uses the FTM_SetupOutputCompare library function. The MCUXpresso SDK API description states:
"When the FTM counter matches the value of compareVal argument (this is written into CnV reg), the channel output is changed based on what is specified in the compareMode argument."
When I change the value of the compareVal argument and re-build and run, there is no change in the output. Are you suggesting that this function doesn't work as advertised?
Thanks,
John
Q: Are you suggesting that this function doesn't work as advertised?
A: No. The channel output is changed based on what is specified in the compareMode argument, but it's hard to observe when you has only one channel.(The CnV only move the waveform, it can not change the frequency. The frequency is related to MOD, you need to use FTM_SetTimerPeriod change the frequency.)
You may need to add another channel and only modify one of them. Then you can observe the waveform move.
I modified my code to use the FTM_SetTimerPeriod() function and it works as you described.
Thanks for the clear and helpful answer.
John