How to use the FTM for CPWM output?

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

How to use the FTM for CPWM output?

Jump to solution
1,974 Views
changkenta
Contributor II

Hello,

I want to use the FTM for 6 channel CPWM output for 3-phase motor control, and on the MK60DN512VLL10 datasheet and reference manual do not show it. Is there any document for me to know How to setting the FTM to generate 6 channel CPWM output?

Regards,

Kenta 

0 Kudos
1 Solution
1,443 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Kenta,

    If your question is solved, could you mark your question as solved?

    Thank you very much!

Jingjing

View solution in original post

0 Kudos
15 Replies
1,443 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Kenta,

     Please find the application note in the attachments, maybe it is useful to you!

    By the way, there has another post:K60 PWM phase?  for your reference!

    Wish it helps you!

Best regards!

Jing

0 Kudos
1,443 Views
changkenta
Contributor II

Hi Jingjing,

Thanks.

by the way, I hope to setting FTM generate 6 channel CPWM output by Processor Expert, but do not succeed.

please let me know How to do it?

Regards,

kenta

0 Kudos
1,443 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Kenta,

    I create a project base on TWR-K60D100M, and use the PE,  choose init_FTM component .

    Now in my project, I configure 2 channels, and test OK, you can refer to it, and create the other 4channels.

   My configuration is as follows,  please find my project from the attachments.

pastedImage_0.png

The test result is :

11.jpg

Wish it helps you!

If you still have question, please contact me!

Thank you and best regards!

Jing

0 Kudos
1,443 Views
changkenta
Contributor II

hi Jingjing,

thanks. I can setting FTM to generate CPWM output.

next, I want to study hot to update the PWM-duty for Sine PWM algorithm?

Regards,

Kenta


0 Kudos
1,443 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Kenta,

    About how update the PWM-duty for sine PWM algorithm, please find it in the AN3729 which I already give you!

   chapter 3.2 sine wave generation.

   By the way, this AN maybe help you too,  the link is :

http://cache.freescale.com/files/microcontrollers/doc/app_note/AN4429.pdf?fromsite=zh-Hans

Best regards!

Jing

0 Kudos
1,443 Views
changkenta
Contributor II

hi Jingjing,

thanks for your share.

I found, I can not update the FTM0_CnV in PE_ISR(FTM_OVER). could you please let me know: How to update the FTM0_C0V, FTM0_C1V?

Regards,

Kenta


0 Kudos
1,443 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Kenta,

    I already try it, the PWM-duty can be changed in the interrupt function. Of course, this method is not work in PWM synchronization.

    I don't know how you to update the FTM0_C0V. I use the following code. you can try it!

/* User includes (#include below this line is not maintained by Processor Expert) */

PE_ISR(FTM_OVER)

{

// NOTE: The routine should include actions to clear the appropriate

//      interrupt flags.

//

      FTM0_SC  &= ~FTM_SC_TOF_MASK;

      FTM0_C0SC &= ~FTM_CnSC_CHF_MASK ;

      FTM0_C1SC &= ~FTM_CnSC_CHF_MASK ;

    

      /* FTM0_C0V: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,VAL=0x05DC */

      FTM0_C0V = FTM_CnV_VAL(0x05DC);                                

      /* FTM0_C1V: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,VAL=0x05DC */

      FTM0_C1V = FTM_CnV_VAL(0x07D0);  

}

In this code, I just change the FTM0_C1V from 1500(0x05DC) to 2000(0x07D0), and the result is as follows, you will find the duty of C1 is changed.

8.jpg

If you still have question, please contact with me!

I wish my answer is useful to you!

Best regards!

Jingjing

0 Kudos
1,443 Views
changkenta
Contributor II

hi Jingjing,

Yes, do not work in PWM sync.

I follow your code, and FTM0_C0V is updated.

thank you.

another Question is: I Do not know How to setting K60 after power on reset, immediately Run the code?

please let me know ...

Regards,

Kenta

0 Kudos
1,443 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Kenta,

   Could you describe your question in details?

   What do you want to setting?

Regards,

Jingjing

0 Kudos
1,443 Views
changkenta
Contributor II

hi Jingjing,

I found that after I download the code into K60, and power Off the K60 board, then re-power On the K60 board, the K60 do not Run the code.

is this the power On reset setting issue ?

Regards,

Kenta

1,443 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Kenta,

   Please configure like this picture:

10.jpg

make sure in Flash, not in RAM.

Then download the code.

Wish it helps you!

Best regards!

Jingjing

0 Kudos
1,443 Views
changkenta
Contributor II

hi Jingjing,

follow the Flash configure, ... the code is Running after power On.

thank you so much.

Regards,

Kenta

1,444 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Kenta,

    If your question is solved, could you mark your question as solved?

    Thank you very much!

Jingjing

0 Kudos
1,443 Views
changkenta
Contributor II

hi Jingjing,

Yes, but I am a new guy, please let me know How to mark my question is solved?

Regards,

Kenta

0 Kudos
1,443 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Kenta,

   You already done it!

   Just mark the correct answer!

    Thank you very much!

Best regards!

Jingjing

0 Kudos