1 Reply Latest reply on Aug 23, 2020 10:42 PM by YatheeshK_36

    FX3 changing PWM frequency while running

    sj_1680686

      I need to generate clock with frequency changing between 2MHz and 2.2MHz in every 10 periods. I could generate the clean PWM with

          gpioComplexConfig.outValue    = CyFalse;
          gpioComplexConfig.inputEn     = CyFalse;
          gpioComplexConfig.driveLowEn  = CyTrue;
          gpioComplexConfig.driveHighEn = CyTrue;
          gpioComplexConfig.pinMode     = CY_U3P_GPIO_MODE_PWM;
          gpioComplexConfig.intrMode    = CY_U3P_GPIO_NO_INTR;
          gpioComplexConfig.timerMode   = CY_U3P_GPIO_TIMER_HIGH_FREQ;
          gpioComplexConfig.timer       = 0;
          gpioComplexConfig.period      = (93-1);
          gpioComplexConfig.threshold   = (47-1);
      
          status = CyU3PGpioSetComplexConfig(GPIO_42, &gpioComplexConfig);
      

       

      But when I use the interrupt as:

      gpioComplexConfig.intrMode = CY_U3P_GPIO_INTR_TIMER_ZERO;
      

       

      I start to get jitters in the clock:

      even when the callback function is empty.

       

      I tried to use CyU3PGpioComplexUpdate() in the callback to change the period,

      void onCallback(uint8_t gpio_id) {
                  g_timerIntrCount++;
              
                  if (g_timerIntrCount == 20){
                      CyU3PGpioComplexUpdate(gpio_id, 46, 92);
                      g_timerIntrCount = 0;
                  }    
                  else if (g_timerIntrCount == 10){
                      CyU3PGpioComplexUpdate(gpio_id, 46, 93);
                  }
      }
      

       

      but the jitters still occur. How can I solve this issue?