This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28375D: recommended on/off method of PWM

Part Number: TMS320F28375D

reading through the ePWM for the part, I can see how to create the desired waveform...

I guess the question is:

1.  how can I start and stop the PWM and do it at the cycle start and end times... ie: when I start it I want to start it at a known start place., when I stop it, I essentially want it to complete wherever its at to the same start position so a full cycle executes, it doesn't stop mid stream.

My issues at the moment is, it looks like you provide the sync signal, which I could issue by software, which would set the counter to a controlled start position... this is desirable, however, you have the 'freeze' control in a separate location... is it possible to 'freeze it' and when the sync pulse is issued it not only starts counting by the preloaded value but changes out of freeze mode to the desired up/dowon or up or down mode?  This doesn't look like it is possible at the moment...

It doesn't have to be that way, but I guess the question is , how can I hold the counter at the start value until I'm ready (issue a software trigger) to start counting?

Also, with regard to stopping the unit..  using the event trigger I could use the time based counter equal to zero (or a compare register, whichever) and generate an interrupt, but then the CPU would have to write to the freeze register to freeze it....  since the PIE/CPU isn't guaranteed timing wise, the counter may start into a new cycle... is there anyway to 'terminate cleanly at the end of a cycle and wait for the next START?

Thanks.

  • Hi Rob,

    In many systems where a C2000 is used, an ISR will be generated every PWM cycle.  In this interrupt it is common to run some kind of control loop, using an data from recently converted ADC sample(s), and then updating some PWM registers based on the result.  In most situations, the PWM update will utilize the ePWM's shadow mode.  I think understanding the shadow mode will play a part of resolving your concerns.

    For your situation, even though you may or may not be running a control loop, you can utilize a similar philosophy.  Use CMPA to set your duty cycle either to 0 or whatever is valid.  Have a PWM interrupt be generated a few cycles into each PWM period (via CMPB).  There you'll update CMPA (shadow register) and it will get updated to the active register automatically when the PWM timer returns to 0.

    On top of this method, synchronization can be useful in you want to start the PWM based on some external event (or an upstream PWM), if desired.

    Hopefully this gives you some ideas.  There are other potential methods for doing things like this, if this doesn't work for your situation (like if the PWM being output is to have a >2MHz period).  However, this is often adequate.


    Thank you,
    Brett

  • void buck_On(void)
    {
    	EALLOW;
    
    		EPwm1Regs.CMPA.bit.CMPA 		= 0;//Duty zero
    		EPwm1Regs.AQSFRC.bit.RLDCSF		= 1;//Load on event counter equals period
    		EPwm1Regs.AQCSFRC.all			= 0;//Forcing disabled, i.e., has no effect
    
    	EDIS;
    }
    
    void buck_Off(void)
    {
    	EALLOW;
    
    		EPwm1Regs.AQSFRC.bit.RLDCSF		= 1;//Load on event counter equals period
    		EPwm1Regs.AQCSFRC.all			= 1;//Forces a continuous low on output A
    
    	EDIS;
    }

    Usually I use this routine to start/stop PWM