PWM value update with PE Init_FTM component

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PWM value update with PE Init_FTM component

1,263 Views
brunotremblay
Contributor III

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

Tags (1)
0 Kudos
6 Replies

908 Views
alexeyusoltsev
Contributor IV

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.

0 Kudos

908 Views
brunotremblay
Contributor III

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 :

pastedImage_0.pngpastedImage_1.png

I found the "AN4560 PWM Synchronisation Using Kinetis Flextimers" app. note, maybe with that I will find something to help me.

Regards,

Bruno

0 Kudos

908 Views
alexeyusoltsev
Contributor IV

  Hi again!

Yes, this is very helpfull appnote.

Init component:INIT.jpg

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?

908 Views
brunotremblay
Contributor III

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

0 Kudos

908 Views
tommyliu
Contributor I

Dear Bruno,

    I also used PDD.  Which command use for "value update". Please tell me. Many thanks.

  :smileyhappy:

0 Kudos

908 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Tommy,

If software trigger is initialized, FTM_PDD_PWMSoftwareTrigger() can be used to trigger "value update".

FTM_PDD_PWMSoftwareTrigger.png

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.

26.4.11.6 C(n)V and C(n+1)V register synchronization.png

So see chapter "26.4.11.4 MOD register synchronization":

Figure 26-44. MOD register synchronization flowchart.png

Best Regards,

Robin

0 Kudos