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.

LAUNCHXL-F28027 Symetric PWM

Hi,

Im looking to produce a symmetric 500khz wave to be a carrier wave for my application.

i wrote the following but i cannot see anything coming out of GPIO0 or GPIO1 in j6.

can anyone help please?

the code:

#define period 500//60   // 500kHz when PLL is set to 0xC (60MHz)

// period 500   // 60kHz when PLL is set to 0xC (60MHz)

//      period 250             // 120kHz when PLL is set to 0xC (60MHz)

Uint16 duty_cycle_A=250; // Set duty 50% initially

Uint16 duty_cycle_B=250; // Set duty 50% initially

main()

{

InitSysCtrl();

DINT;

  IER = 0x0000;

  IFR = 0x0000;

InitEPwmGpio();

  // Time-base registers

  EPwm2Regs.TBPRD = period;          // Set timer period, PWM frequency = 1 / period

  EPwm2Regs.TBPHS.all = 0;   // Time-Base Phase Register

  EPwm2Regs.TBCTR = 0;   // Time-Base Counter Register

    EPwm2Regs.TBCTL.bit.PRDLD = TB_IMMEDIATE;  // Set Immediate load

    EPwm2Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Count-updown mode: used for symmetric PWM

EPwm2Regs.TBCTL.bit.PHSEN = TB_DISABLE;   // Disable phase loading

EPwm2Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_DISABLE;

EPwm2Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1;

EPwm2Regs.TBCTL.bit.CLKDIV = TB_DIV1;

  // Setup shadow register load on ZERO

  EPwm2Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;

  EPwm2Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;

  EPwm2Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; // load on CTR=Zero

  EPwm2Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO; // load on CTR=Zero

  // Set Compare values

  EPwm2Regs.CMPA.half.CMPA = duty_cycle_A;    // Set duty 50% initially

  EPwm2Regs.CMPB = duty_cycle_B;             // Set duty 50% initially

  // Set actions

  EPwm2Regs.AQCTLA.bit.CAU = AQ_SET;            // Set PWM2A on event A, up count

  EPwm2Regs.AQCTLA.bit.CAD = AQ_CLEAR;          // Clear PWM2A on event A, down count

  EPwm2Regs.AQCTLB.bit.CBU = AQ_SET;            // Set PWM2B on event B, up count

  EPwm2Regs.AQCTLB.bit.CBD = AQ_CLEAR;          // Clear PWM2B on event B, down count

EPwm2Regs.CMPA.half.CMPA = duty_cycle_A;      // Add duty_cycle_A to watch window

  EPwm2Regs.CMPB = duty_cycle_B;               // Add duty_cycle_B to watch window

while(1){}

}