Conditionally setup FTM Output Compare

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Conditionally setup FTM Output Compare

3,298 次查看
aberger
Contributor V

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.

DDS_with_outputCompare.png

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?

标签 (1)
标记 (3)
0 项奖励
24 回复数

172 次查看
vic_tagayun
Contributor I

Newbie here, sorry for stupid question, how did you able to show the GUI for FTM?

0 项奖励

172 次查看
aberger
Contributor V

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.

0 项奖励

172 次查看
vic_tagayun
Contributor I

Hello, I find that the Peripherals gui is not present and supported on KV46 as shown below.

peripherals.jpg

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.

0 项奖励

172 次查看
Hui_Ma
NXP TechSupport
NXP TechSupport

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":

pastedImage_1.png


Have a great day,
Mike

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励