• AVR Freaks

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/23 03:07:19 (permalink)
0

PWM's special event interrupt issue.

Dear Support team, We are using dsPIC33EV256GM106 in our one of the project. I am using a PWM module having two output such as PWM2 and PWM3 with complementary enabled. I am trying to change the PHASE shift between the two PWMS using PHASE value. If I change PHASE value of PWM2, 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

1 Reply Related Threads

    du00000001
    Just Some Member
    • Total Posts : 3310
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: PWM's special event interrupt issue. 2020/01/07 14:21:39 (permalink)
    0
    Please tell us which of your 2 threads is the one we should follow!

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #2
    Jump to:
    © 2020 APG vNext Commercial Version 4.5