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.

TMS320F28075: Using PWMxA&B with different frequency.

Part Number: TMS320F28075

Dear support,

I have 2 peripherals connected to the my TMS320F28075 to the same PWM (PWM11).

One to the A (gpio20).

One to the B (gpio21).

I need to configure them to different frequency (200Hz and 1000Hz). 

Is it possible? Both of them share the same TBPRD register...

By playing with the CMPA/B registers, I can set different duty cycle to A and B, but the frequency is common for both of them.

Thanks in advance,

Alex.

  • Due to US holidays, you can expect a response by 3'rd Dec.

  • Well obviously the easiest way would be to use two different ePWM modules (ePWM11 and ePWM10 for example).

    But for your specific setup, using one ePWM module's output A and B. You have to set the PWM frequency to 1000Hz (set the TBPRD accordingly) and then do the math to generate 200Hz signal every 5 PWM periods. This requires you to set up the ePWM interrupt and change your CMPx and action qualifiers when the interrupts occur.

    Nima

  • Thanks a lot for your answer. 

  • Hi Nima,

    Typically it is ill advised to change any modules period while it is PWM'ing a device or at all as you described for a second option. How is the ePWM not prone to the same destructive mayhem that can occur to others by doing what you advised? 

    Seemingly your first answer of two generators would be more prudent and far less prone to electrical errors during duty cycle updates. 

  • On my answer for the second part, the PWM period is not changing (TBPRD). It is just selected to match the higher frequency PWM and then mathematically you can create lower frequency PWM waves, by selecting different actions every X number of PWM periods.

  • Nima Eskandari said:
    by selecting different actions every X number of PWM periods.

    I still fail to see how the frequency can be made lower on PWM-B if the period has not been changed at the generator level. Other TI ePWM modules do not work well or even allow B side generator to have a different period load value than PWM- A, ignores the change or locks. Same issues occur for CMP-B for duty cycle updates, yet no such errata was ever listed. The match value loaded into CMP-B can not be significantly > than CMP-A or mayhem occurs.

    So the action qualifier allows independent generator frequency changes after the period initial setting without any mayhem? Changing CMP-B value only alters the duty cycle in other TI ePWM modules and not the period.

    How can AQ of CMP-B modify generator B period for 200Hz without a new count load value input as generator B period? Seeminly the AQ can only change the duty cycle, not the frequency (period).

  • Okay here is what I'm saying you can do:

    TBPRD = 1000
    
    Output A:
    
    CTR=ZERO, Clear the output LOW
    
    CTR=CMPA, Set the output HIGH
    
    Now you have your high frequency signal
    
    
    
    Output B:
    
    software_register_keeping_track_of_how_many_periods = 0;
    
    __interrupt EPWM1()
    
    {
    
    	software_register_keeping_track_of_how_many_periods ++;
    
    	if (software_register_keeping_track_of_how_many_periods == 10)
    
    	{
    
    		software_register_keeping_track_of_how_many_periods = 0;
    
    		//Update Actions
    
    		ZERO :
    
    		CMPB : 
    
    		PRD :
    
    	}
    
    	else if (if (software_register_keeping_track_of_how_many_periods == SOME_OTHER_NUMBER_BETWEEN_0_AND_10)
    
    	{
    
    		//Update Actions
    
    		ZERO :
    
    		CMPB : 
    
    		PRD :
    	}
    
    	else
    
    	{
    
    		//Update Actions
    
    		ZERO :
    
    		CMPB : 
    
    		PRD :
    
    	}
    
    }
    
    

    This gives you technically 10 times lower frequency.