• AVR Freaks

dsPIC33EV256GM106 PWM's special event interrupt issue.

Author
hari4782kumar
New Member
  • Total Posts : 2
  • Reward points : 0
  • Joined: 2019/02/21 22:33:15
  • Location: 0
  • Status: offline
2019/12/27 02:11:47 (permalink)
0

dsPIC33EV256GM106 PWM's special event interrupt issue.

Dear Support team, We are using dpPIC33EV256GM106 in our one of the project. I am using a PWM module having two output with complementary enabled. I am trying to change the PHASE shift between the two PWMS using PHASE value. If I change PHASE value, the PWM cycle's special event interrupts are not triggering. The PWM is operating with 40KHz with MASTER mode. I've verified the PHASE value, it is always less than the period value.
why are the interrupts are not working.
The below are the code snippet.
void PWM_Initialize (void)
{
    PTCON2 = 0x1;
    PTPER = 0x3E8; //1000
    SEVTCMP = 0xFA; //250
    MDC = 0x1F4; //500 50%duty
    PWMKEY = 0x0;
    PWMCON1 = 0x0;
    PWMCON2 = 0x0;
    PWMCON3 = 0x0;
    __builtin_write_PWMSFR(&IOCON2, 0x302, &PWMKEY);
    __builtin_write_PWMSFR(&IOCON3, 0x302, &PWMKEY);
    __builtin_write_PWMSFR(&FCLCON2, 0x3, &PWMKEY);
    __builtin_write_PWMSFR(&FCLCON3, 0x3, &PWMKEY);

    PHASE1 = 0x0;
    PHASE2 = 0x0;
    PHASE3 = 0x0;
    DTR1 = 0x0;
    DTR2 = 0x5;
    DTR3 = 0x5;
    ALTDTR1 = 0x0;
    ALTDTR2 = 0x5;
    ALTDTR3 = 0x5;
    TRIG1 = 0x0;
    TRIG2 = 0x0;
    TRIG3 = 0x0;
    TRGCON1 = 0x2C;
    TRGCON2 = 0x2C;
    TRGCON3 = 0x0;
    PWMCAP1 = 0x0;
    PWMCAP2 = 0x400;
    PWMCAP3 = 0x0;
    LEBCON1 = 0x0;
    LEBCON2 = 0x0;
    LEBCON3 = 0x0;
    LEBDLY1 = 0x0;
    LEBDLY2 = 0x0;
    LEBDLY3 = 0x0;
    AUXCON1 = 0x0;
    AUXCON2 = 0x0;
    AUXCON3 = 0x0;
    
    //Interrupts
    IFS3bits.PSEMIF = false;
    IEC3bits.PSEMIE = true;

    PTCON = 0x8800;
}

void __attribute__ ( ( interrupt, no_auto_psv ) ) _PWMSpEventMatchInterrupt ( )
{
    /*User Code*/
    IFS3bits.PSEMIF = false;


if(PHASE2<0x1D9)
       PHASE2 = PHASE2 + 0x01;
 else if(PHASE2>0x01)
       PHASE2 = PHASE2 - 0x01;

}

Please provide any suggestion for this issue.
#1
Jump to:
© 2020 APG vNext Commercial Version 4.5