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.

Concerto HRPWM period

Other Parts Discussed in Thread: F28M35H52C

Hello,

I  try to use the HRPWM for the period on my F28M35H52C but I don't get the high résolution.

Con I have a comment on the following sample.

Best regards

//---------------------------------------------------------------------
// ePWM1
//---------------------------------------------------------------------
// Note EPWM1 is the Master
//Time Base SubModule Register
(*ePWM[1]).TBCTL.bit.PRDLD = TB_SHADOW; // High resolution period : must be shadow
(*ePWM[1]).TBCTL2.bit.PRDLDSYNC = 0; // Load PRD when - 0 : CTR = 0; - 01 : on Sync or CTR = 0; - 10 : only on sync
(*ePWM[1]).TBCTL.bit.CTRMODE = TB_COUNT_UP; // High resolution period : not compatible with down-count mode
(*ePWM[1]).TBCTL.bit.PHSEN = TB_DISABLE;


(*ePWM[1]).TBCTL.bit.PHSDIR = TB_UP;
(*ePWM[1]).TBCTL.bit.SYNCOSEL = TB_CTR_CMPB; //Synchronization of PWM2 will be set on CTR = CMPB 

(*ePWM[1]).TBCTL.bit.HSPCLKDIV = TB_DIV1; //High resolution period : TBCLK must equal SYSCLKOUT
(*ePWM[1]).TBCTL.bit.CLKDIV = TB_DIV1;

(*ePWM[1]).TBPHS.half.TBPHS = 0;

(*ePWM[1]).TBPRDM.all = ui32PwmHRPeriod - 1;
(*ePWM[1]).TBCTR = 0;

// Counter compare submodule registers
(*ePWM[1]).CMPCTL.bit.SHDWAMODE = CC_SHADOW;
(*ePWM[1]).CMPCTL.bit.SHDWBMODE = CC_SHADOW;
(*ePWM[1]).CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; //Load A on Zero
(*ePWM[1]).CMPCTL.bit.LOADBMODE = CC_CTR_ZERO; //Load B on Zero

(*ePWM[1]).CMPA.all = ui32PwmHRDutyCycle; //will be used for switching off PWM1A

//---------------------------------------------------------------------

// Configure HRPWM

// Clear all bits first
(*ePWM[1]).HRCNFG.all = 0x0;

//Selects the edge of the PWM that is controlled by the micro-edge position (MEP) logic:
(*ePWM[1]).HRCNFG.bit.EDGMODE = HR_BEP; // EDGE MODE :
// 00 HRPWM capability is disabled (default on reset)
// 01 MEP control of rising edge (CMPAHR)
// 10 MEP control of falling edge (CMPAHR)
// 11 MEP control of both edges (TBPHSHR or TBPRDHR)

//Selects the register (CMP/TBPRD or TBPHS) that controls the MEP
(*ePWM[1]).HRCNFG.bit.CTLMODE = HR_CMP; // 0 CMPAHR(8) or TBPRDHR(8) Register controls the edge position
// (i.e., this is duty or period control mode). (Default on Reset)

//Selects the time event that loads the CMPAHR shadow value into the active register.
(*ePWM[1]).HRCNFG.bit.HRLOAD = HR_CTR_ZERO; // 00 Load on CTR = Zero: Time-base counter equal to zero (TBCTR = 0x0000)//Selects the edge of the PWM that is controlled by the micro-edge position (MEP) logic:

(*ePWM[1]).HRCNFG.bit.EDGMODEB = HR_BEP; // EDGE MODE :

//Selects the register (CMP/TBPRD or TBPHS) that controls the MEP
(*ePWM[1]).HRCNFG.bit.CTLMODEB = HR_CMP; // 0 CMPBHR(8) or TBPRDHR(8) Register controls the edge position

//Selects the time event that loads the CMPBHR shadow value into the active register.
(*ePWM[1]).HRCNFG.bit.HRLOADB = HR_CTR_ZERO; // 00 Load on CTR = Zero: Time-base counter equal to zero (TBCTR = 0x0000)

(*ePWM[1]).HRCNFG.bit.AUTOCONV = 1; // Enable autoconversion : must always be enabled for high resolutionperiod

(*ePWM[1]).HRPCTL.bit.TBPHSHRLOADE = 0; // Enable TBPHSHR sync (required for updwn count HR control)
(*ePWM[1]).HRPCTL.bit.HRPE = 1; // Turn on high-resolution period control.
// In this mode the HRPWM module can control high-resolution of
// both the duty and frequency