3 Replies Latest reply on Nov 2, 2017 1:27 AM by anks

    While running, duty cycle change to a PWM block output has glitch.

    user_51239369

      When I change the duty cycle for my LED pwm output, before going to dim it turns off, and then, goes to dim.  Seems like it is glitching.  Is there a solution for this or am I doing something wrong?

       

      Below are my values for period and compare:

       

      // Period, Compare value

          {65535,     0},//0 OFF

          {65535, 65535},//1 ON

          {65535, 32000},//2 BLINK

          {100,      75} //3 DIM

      };

       

      Here is my function:

       

      static void SetPWMLEDIndicators(void){

          uint8 BtnLoc;

          uint16 wPeriod, wCMP;

          for(BtnLoc = 0; BtnLoc < NUM_PHYSICAL_BUTTONS; BtnLoc++){

              if(wLEDIndicatorPWMSrvMask & (1 << BtnLoc)){

                  wPeriod = abLEDindicPWMRxMsg[BtnLoc][0];

                  wCMP = abLEDindicPWMRxMsg[BtnLoc][1];

                  ChangeLEDMode((BtnLoc + 1), wPeriod, wCMP);           

                  wLEDIndicatorPWMSrvMask &= ~(1 << BtnLoc);

              }

          } 

      }

      PWM Mode: One Output

      CMP Type 1: Greater or Equal

      Dead Band: Disable

      Enable Mode: Software Only

      Run Mode: Continuous

      Trigger Mode: None

      Kill Mode: Disableed

      Capture Mode: None

      Interrupts: None

       

      extern void ChangeLEDMode(LOGICAL_STATION_BUTTON button, uint16 wPeriod, uint16 wCMP){  

          switch(button){

              case TOP:

                  PWM_TL_WritePeriod(wPeriod);

                  PWM_TL_WriteCompare(wCMP);

                  break;

              case MIDDLE:

                  PWM_ML_WritePeriod(wPeriod);

                  PWM_ML_WriteCompare(wCMP);

                  break;

              case BOTTOM:

                  PWM_BL_WritePeriod(wPeriod);

                  PWM_BL_WriteCompare(wCMP);

                  break;

              default:

                  break;

          }

      }

       

      Appropriate help!