I am trying to use Output Compare to set (and clear) an FTM channel as a square-wave output, synchronized to a direct digital synthesis (DDS) waveform being generated by the same FTM module.
The FTM_MOD determines the update frequency of the 32-bit DDS phase accumulator. On each FTM overflow, the DDSphase accumulator is incremented by the frequency tuning word (FTW). When the phase accumulator is within a single FTW of overflowing, I calculate the FTM Count at which the projected DDS phase is expected to overflow, and set the Output Compare register to this value. (I am using the FTM_SetupOutputCompare() function from the fsl_ftm.c driver module to do so).
Strangely, when I observe the relative timing of the DDS update and the Output Compare "set", they are always separated by some fixed delay, and not by the value I have calculated. This fixed delay occurs regardless of the FTW (i.e. the DDS output frequency). The fixed delay also occurs if I manually set the Output Compare value to some fixed number less than FTM_MOD, instead of using the formula from the above figure. (For concreteness, the measured delay is almost one full FTM_MOD period).
Is there some reason that the Output Compare register would not be updated immediately?
This is part of the MCUXpresso Config Tools application. You can either run that program directly, or from the MCUXpresso IDE click Window > Perspective > Open Perspective > Other > Peripherals. You should then see all the peripherals listed. If you double click on an FTM module in the Peripherals list, it will open the GUI configuration for that module.
Hello, I find that the Peripherals gui is not present and supported on KV46 as shown below.
Is it also stated in another website shown below.
https://mcuoneclipse.com/2019/06/16/new-nxp-mcuxpresso-ide-v11-0/#comment-157708
Can you confirm this limitations on KV4 and KV5?
Or there is something I am missing. If so, this needs to study "very deep" into the API for a new comer like me.
Hi,
Please you provide the FTM register value for double check.
Do you using the K64 chip?
From the MCUXpresso Config tool, the Channel setting provides pin function selection, such as "Output compare":
Have a great day,
Mike
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------