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.

Dual PWM Interrupt C2000

Hello dear specialists! =)

I am using F2808 MCU. I set settings for my PWM interrupt to CompareA. How I can set setting for my PWM to Interrupt by CompareA and Period?

I want to receive interrupt by CompareA and by Period. 

// Step 3. Clear all interrupts and initialize PIE vector table:
...
PieVectTable.IntVectorCompPWM1_ARM1=&InterruptCompPWM1_ARM1;
...

// Step 4. Initialize the Device Peripheral
...
InitPWM(&PWM1_ARM1_3Ph, &PWM1_ARM2_3Ph, &PWM1_ARM3_3Ph);
...

// Step 5. User specific code, enable interrupts:
...
IER|=M_INT3;							// PWM 1, 2, 3, 4, 5, 6
...
PieCtrlRegs.PIEIER3.bit.INTx1=ENA;	// PWM - EPWM1_INT Group 3, interrupt 1
...


/* ===== Initializations PWM ===== */
struct EPWM_REGS *ARM1

	ARM1->TBPRD=REG_PERIOD_PWM1_3Ph;			// Period
	ARM1->CMPA.half.CMPA=REG_PERIOD_PWM1_3Ph/2;	// Q=2
	ARM1->TBPHS.half.TBPHS=0; 					// Set Phase register to zero
	ARM1->TBCTL.bit.FREE_SOFT=2;				// Ena FreeRun mode
	ARM1->TBCTL.bit.PHSEN=TB_DISABLE;			// Master module
	ARM1->TBCTL.bit.PRDLD=TB_SHADOW;			// Ena shadow
	ARM1->TBCTL.bit.SYNCOSEL=TB_CTR_ZERO;		// Sync down-stream module
	ARM1->TBCTL.bit.CLKDIV=CLK_TB_DIV;			// Div=8
	ARM1->TBCTL.bit.HSPCLKDIV=TB_DIV2;			// Div=2
	ARM1->CMPCTL.bit.SHDWAMODE=CC_SHADOW;		// Ena shadow
	ARM1->CMPCTL.bit.SHDWBMODE=CC_SHADOW;		// Ena shadow
	ARM1->CMPCTL.bit.LOADAMODE=CC_CTR_ZERO;		// Load on CTR=Zero
	ARM1->CMPCTL.bit.LOADBMODE=CC_CTR_ZERO;		// Load on CTR=Zero
	ARM1->AQCTLA.bit.PRD=AQ_NO_ACTION;			// Set actions for EPWMxA in PERIOD
	ARM1->AQCTLA.bit.CAU=AQ_NO_ACTION;			// Set actions for EPWMxA in UP
	ARM1->DBCTL.bit.OUT_MODE=DB_DISABLE;		// Disable Dead-band module

	ARM1->ETCLR.bit.INT=1;						// Reset
	ARM1->ETSEL.bit.INTSEL=ET_CTRU_CMPA;		// Interrupt by CMPA when the timer is incrementing
	ARM1->ETSEL.bit.INTEN=ENA;					// Enable interrupt
	ARM1->ETPS.bit.INTPRD=ET_1ST;				// Interrupt Event 	(on the first event)

  • Potapov,

    Unfortunately that option doesn't exist on F2808. You can generate an interrupt on PRD or CMPA, but not both.

    Depending on what you are doing you might be able to re-configure the ETSEL register within an ISR to toggle continually between the two interrupt events, but that can lead to timing issues.

    Alternatively, you could generate PWM at a pin (here you seem to have both PRD and CAU set to 0), then connect that pin to an external interrupt pin and trigger an interrupt from that.

    The only other way I can think of is to allocate a separate PWM module to generate the other interrupt. If you have a spare PWM module, you can configure it to the same frequency and lock the phases together.

    It's probably not much help to point out that newer devices (e.g. F28075) can generate interrupts in this way.

    Regards,

    Richard
  • Richard Poley,

    Thanks for your answer.
    Do I understand, that the new MCU (such as F28075 and TMS320F28379x) can implement two interrupts by one PWM (CMPA and PRD)?
    I looked their datasheets, but I cannot understand, how can I set settings for this mode?

    Also, C2000 PWMs have interesting "Chopper (PC) Submodule", but his frequency is so high (Mhz). Can I setup this Chopper to freq.~4-10kHz?
  • Potapov,

    You're welcome.

    The F28x7x devices have four comparator registers in each PWM module. In addition to the CMPA/B of the earlier devices, CMPC/D can be used to position ADC conversions and/or interrupts. To trigger an interrupt on the period event you could position CMPC adjacent to the period event (one cycle below), then use either option 100 or 101 in the INTSEL field of the ETSEL register. There would be one TBCLK cycle difference between PRD and the interrupt trigger.

    Unfortunately there is no way to reduce the chopper module frequency to the 4-10kHz range. It was designed to operate with pulse transformers (e.g. for gate drive isolation) which typically require much higher frequencies.

    Regards,

    Richard
  • Richard Poley,

    It would be nice if You would do MCU chopper for lower frequency (10-100 kHz). I also use pulse transformer, but somewhat powerful.
    It is my wish =)

    Thanks.