restarting PWM in DSC 56F83xx IN THE MIDDLE OF PWM CYCLE.

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

restarting PWM in DSC 56F83xx IN THE MIDDLE OF PWM CYCLE.

972 次查看
dmitryrogachev
Contributor II

Re: PWM @ MC56F8323, F83xx, F832x, F8xxx, etc.

 

Hello, everybody.

 

Does anybody knows - how to interrupt the ongoing PWM cycle and restart it say with the different duty cycle?

For the motor control it is often desired not to wait until the PWM cycle ends, but interrupt it and restart the new one.

Is it a way to cause the transfer without waiting the end of cycle (half cycle in some cases)?

These chips does not allow to write directly to the counter PMCNT.

 

I was trying to disable the PWM module (PMCTL &= 0x3,  bits LDOK and PWMEN), to stop PWM, and restart PWM with all same parameters:

It does not work.

 

QUESTIONS:

1. Is there a better way to interrupt PWM cycle than resetting the whole module?

2. What parameters do I need to set, so re-initialization would actually work?

 

Thanks,

Dmitry.

 

Code example:

Here PWM works and outputs.

PW
     PWM->CTL &= 0x0003;  // disable pwm to reset the cycle
   PWM->OUT =  0x8000 | (~(commutation_state_table[commutation_state])&0x3FFF); // configure outputs from the array of states
   PWM->CTL |= 0x0002;                          // set LDOK
   PWM->CTL &= 0x0020;                        // clear PWMIE (int)
   PWM->CTL |= 0x0001;                         // set PWM ENABLE
  
标签 (1)
0 项奖励
4 回复数

746 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Dmitry,

The PWM module of MC56F83xx is simple, it does not support the function that  PWM counter synchronizes with external signal.

I do not understand your application, do you have an external  synchronizing signal which you want to synchronize the PWM module? If you have such external signal, it is okay.

For the MC56F803x for example MC56F8037, we have updated the feature of PWM design, and add the "External Synchronization of PWM Counting" function, the external signal on the FAULT2 pin can synchronize the PWM counter and clear the PWM counter when the edge of synchronizing signal occurs. I copy it here, pls download the Reference manual of MC56F8037 from the website:

Digital Signal Controllers|NXP

If you do not have external signal and you just want to check the PWM counter when it reaches a predefined value and restart the PWM counter, I think you can use a GPIO as output signal which can be connected to Fault2 pin as a synchronization signal, while you can set/clear the GPIO to synchronize the PWM module by software.

If you use the latest DSC with eFlexPWM module fro example MC56F84xxx or MC56F827xx, it is okay, the eFlexPWM has dedicated synchronization signal pin PWM[n]_EXT_SYNC, which can synchronize the PWM counter. The kinetis family with FlexTimer module also support the synchronizing function for example KV or Kinetis k10/K20/K30/K40/K50/K60.

I copied from RM of MC56F8037:

"

8.6.13 External Synchronization of PWM Counting

When not being used as a fault input, the FAULT2 pin may be used for external synchronization. If

SYNC_OUT_EN is set, a positive pulse is put out on FAULT2 at the start of every cycle. The polarity of this bit

can be changed by the FPOL2 bit. This pulse can be used to synchronize other PWMs.

If SYNC_OUT_EN is clear and SYNC_WINDOW has a value other than zero, input synchronization is enabled.

FAULT2 is the external sync input and must not be used as a fault input. The DISMAP register should be set so

FAULT2 does not disable any of the PWM outputs. Filtering of the external sync input is controlled with the

FFILT2 register and polarity is controlled by FPOL2. Upon recognizing an incoming pulse, the PWM counter is

reset to zero if the current counter value is within the window defined by SYNC_WINDOW bit field.

"

BR

Xiangjun Rong

0 项奖励

746 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Dmitry,

Thank you for your feedback, I see your scenario that you do not design a new product.

Regarding the debugging issue, I suggest you clear the DBG_EN bit in PMCFG, in the case, the PWM pin will be in INACTIVE when the chip enters Debug mode.

Regarding your second task to interrupt the ongoing PWM cycle and restart it with the different duty cycle, for PWM signals, as you know that it is a target of PWM design to keep the PWM signals intact, so your application is not a regular utilization.

It seems your code is okay to restart the PWM by clearing both LDOK and PWMEN bits in PMCTL register, then setting up the NEW parameter for PWM, setting both the LDOK and PWMEN. what is problem now for the following code?

void Commutation_Control()

{

    static UInt16 commutation_state = 0;

    commutation_state = commutationNextStateFwd[commutation_state];

              // Now in order to start a new PWM cycle at the moment of FETs switching,

        // I am resetting PWM (it stops the current PWM cycle), setting the values

        // setting LDOK (transfer), and enabling (i.e. starting new cycle)

          clrReg16Bits(PWMA_PMCTL, 0x3);      /* PWMA_PMCTL: PWMEN=0, clear PWMEN bit, disable PWM */   

        setReg16(PWMA_PMOUT, pwmStateSelect[commutation_state]);     /* Set new FETs position */

          setReg16Bits(PWMA_PMCTL, 0x2);      /* set LDOK bit, reload&start new PWM should happend @enabling */

          clrReg16Bits(PWMA_PMCTL, 0x20);     /* disable reload int */

          setReg16Bits(PWMA_PMCTL, 0x1);      /* PWMA_PMCTL: LDOK=1, set PWMEN bit, enable PWM */      

}

I can not get an alternative to restart the PWM new cycle besides your solution.

BR

Xiangjun Rong

0 项奖励

746 次查看
johnlwinters
NXP Employee
NXP Employee

The message which included the attachment you wanted deleted have been deleted.

0 项奖励

746 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, John,

Thanks.

BR

XiangJun Rong

0 项奖励