5 Replies Latest reply on Aug 3, 2020 5:48 AM by MoTa_728816

    PWM Updating Speed

    DaMc_1553781

      Hi,

       

      I'm having problems changing the value of my period and compare of my PWM quickly. I'm using two interrupts, one running at a 10ms tick which calculates a new pwm period and compare (compare is always half the period to maintain duty cycle) which is speeding up and slowing down the PWM between a max and a min.

       

      The other interrupt is for the PWM that updates the compare and period on the TC interrupt.

       

      The PWM block is running at 10MHz and i'm trying to get a frequency of around 150k from the PWM. Running at this speed the PWM 'skips' and jitters around.

       

      Questions is, When should the PWM be updated and is it even possible at higher speeds?

       

      i.e.

      CY_ISR(tick)

      {

           pwmPeriod     = newValue;

           pwmCompare = newValue / 2

      }

       

      CY_ISR(pwmTC)

      {

          PWM_ClearInterrupt(PWM_INTR_MASK_TC);

          PWM_WritePeriod(pwmPeriod);

          PWM_WriteCompare(pwmCompare);

      }