Hi,
I'm trying to generate a phase shift PWM signal using 4 channel for the FTM2 on a MKE06Z. I have no problem initialize the PE Init_FTM to generate the signals I want, but I can't change the values (FTM_CnV) register at runtime with the following interface : FTM_PDD_WriteChannelValueReg(FTM2_BASE_PTR,FTM_PDD_CHANNEL_2,Shift);
I've try to call it periodicaly or put it in the OverflowInterrupt, but the value in the register won't change. In the reference manual, it's not clearly explain when, where or how to change or update the channel value.
I also tried the solution of the Update PWM period on runtime post, it works ok for one channel, but I can't combine two channels. Do someone have an idea?
Regards,
Bruno
Hi Bruno,
CnV is double buffered register as is Modulo and some other. So when you writing value to it you are actually writing value to its buffer. To update register with its buffer value you need to make trigger cmd(hardware or software). The easiest way is to use software trigger. Using HAL it is :
FTM_HAL_SetSoftwareTriggerCmd(FTM2,true);
be sure to set software trigger while initializating FTM.
Hope it will help,
Alexey.
Hi Alexey,
Thanks for your reply. Since I use the Init_FTM component, the only macros available are listed below. I don't have any general software trigger command. I tried with initializing all the software trigger with each trigger macro but the value still won't update. Can you tell me which bit in which register the "FTM_HAL_SetSoftwareTriggerCmd(FTM2,true)" macro take action?
Software trigger macros available: Component initialization :
I found the "AN4560 PWM Synchronisation Using Kinetis Flextimers" app. note, maybe with that I will find something to help me.
Regards,
Bruno
Hi again!
Yes, this is very helpfull appnote.
Init component:
and to send software trigger you need to FTM2_SYNC|=FTM_SYNC_SWSYNC(1);
If it will not work check in the debugger mode SYNCCONF register in the FTM.
Why don't you want to use HAL instead of INIT component?
Hi Alexey,
Thanks to you, the value update is now working.
By HAL, I think you mean the LDD components? Initialy, I was wanting to use the Init_FTM componement because in it I was able to initialize all 4 channels with combine, complementary and deadtime at the same time. By using the LDD, I must have a component by channel and do the rest of the settings in my code. At the end, it's longuer but it finaly works.
Thanks again,
Bruno
Dear Bruno,
I also used PDD. Which command use for "value update". Please tell me. Many thanks.
:smileyhappy:
Hi Tommy,
If software trigger is initialized, FTM_PDD_PWMSoftwareTrigger() can be used to trigger "value update".
From the chapter "26.4.11.6 C(n)V and C(n+1)V register synchronization" in MKE06P80M48SF0RM we can know that: The synchronization mechanism is the same as the MOD register synchronization.
So see chapter "26.4.11.4 MOD register synchronization":
Best Regards,
Robin