K22 + KDS+ MQX--> how to use PWM

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

K22 + KDS+ MQX--> how to use PWM

795件の閲覧回数
sudhanshumehta
Contributor IV

Hi Team,

I have K22 1M  device, I am using KDS + MQX (Not KSDK) , I want to use PWM.

How can I do that.

Thanks

Sudhanshu 

0 件の賞賛
3 返答(返信)

529件の閲覧回数
danielchen
NXP TechSupport
NXP TechSupport

Hi sudhanshu mehta :

PWM module does not fall easily into the file I/O module in MQX, it will be better to use processor expert to generate PWM code .

Please refer to the below document for more details

https://community.nxp.com/docs/DOC-329187 

I hope it helps


Have a great day,
Daniel

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

0 件の賞賛

529件の閲覧回数
sudhanshumehta
Contributor IV

Hi Daniel, 

Thanks for your reply. 

I am not using PE. 

My Configuration is I Have 

K22 1M  device, I am using KDS + MQX (Not KSDK) no PE.

Please suggest something.

Do you have some demo code for that.

Thanks

Sudhanshu

0 件の賞賛

529件の閲覧回数
danielchen
NXP TechSupport
NXP TechSupport

Hi Sudhanshu:

I think you can refer to the below code.

/*Using FTM2_CH0 FTM2_CH1 output PWM with 90% high, 10% low wave*/
void FTM_EPWM(void)
{
    PORTA_PCR10 = (0|PORT_PCR_MUX(3)); /* FTM2_CH0 enable on PTA10 */
    PORTB_PCR18 = (0|PORT_PCR_MUX(3)); /* FTM2_CH0 enable on PTB18 */
  
    PORTA_PCR11 = (0|PORT_PCR_MUX(3)); /* FTM2_CH1 enable on PTA11 */
    PORTB_PCR19 = (0|PORT_PCR_MUX(3)); /* FTM2_CH1 enable on PTB19 */

    FTM2_MOD = 0x0063;  /* 0x0063 / 25MHz = 4uS PWM period */
 
      /* Configure timers for edge aligned PWM High True Pulses */
      printf("FTM2_ Edge_Aligned Test 1\r\n");
      printf("Please check the waveform, 90% Hign Ture EPWM\r\n");

      FTM2_C0SC = 0x28;   /* No Interrupts; High True pulses on Edge Aligned PWM */
      FTM2_C1SC = 0x28;  

      FTM2_C0V = 0x005A;  /* 90% pulse width */
      FTM2_C1V = 0x005A;  

      FTM2_SC = 0x08;     /* Edge Aligned PWM running from BUSCLK / 1 */
}   

Please note these codes are not for K22, you need to modify them according to your requirements

Only care will be in case interrupts are needed for FTM application. There are two ways to add user interrupts into an MQX system--Kernel ISR or MQX managed isr.

Regards

Daniel

0 件の賞賛