1 Reply Latest reply on Oct 14, 2019 6:45 AM by KandlaguntaR_36 Branched to a new discussion.

    CX3 Vsync PulseNOW function failing

    ZaTu_4258396

      Hello all I have been working on an issue with our production board and are now changing the LED pulse configuration. Our goal is to run the LED over ~1.8 frames and then turn off. Then on the 2 frame the other LED will turn on. We are using the Vsync pulse as our  interrupt for the LED toggling.

       

      We are  running at 15 fps and that gives us a Vsync of ~66ms. When I have  the  pulseTime set to anything less than 66 ms it functions correctly and each LED will begin its pulse every 4th frame as  it should. However, as soon as I increase it to say 70, both LEDs stay on and do not toggle. I would have expected this if I had the time to be 66*4 = 264 ms. Any help would be appreciated.

       

      Our current setup is the following:

       

         /* Create the thread for the application */

          retThrdCreate = CyU3PThreadCreate(

      &gpioThread, /* GPIO Example App Thread structure */

      "21:GPIO_simple_output", /* Thread ID and Thread name */

      GpioThread_Entry_Simple, /* GPIO Example App Thread Entry function */

      0, /* No input parameter to thread */

      ptr, /* Pointer to the allocated thread stack */

      CY_FX_GPIOAPP_THREAD_STACK, /* Thread stack size */

      CY_FX_GPIOAPP_THREAD_PRIORITY, /* Thread priority */

      CY_FX_GPIOAPP_THREAD_PRIORITY, /* Preemption threshold for the thread. */

      CYU3P_NO_TIME_SLICE, /* No time slice for the application thread */

      CYU3P_DONT_START /* Start the Thread immediately */

      );

       

      Create the thread

      Enter thread

       

      while(1){

      uint32_t eventFlag;

       

       

      // Wait for a VSYNC High Signal before starting the LED Fire process

      CyU3PReturnStatus_t apiRetStatus = CyU3PEventGet( &glFxGpioAppEvent,

      CY_FX_GPIOAPP_GPIO_HIGH_EVENT, CYU3P_EVENT_OR_CLEAR,

      &eventFlag, CYU3P_WAIT_FOREVER);

      if (apiRetStatus != CY_U3P_SUCCESS)

      continue;

       

       

      if (IR_flag == CyTrue)

      {

      //  We are wanting to make sure that we hold the LED flash over the course of  123 msec so

      //  we need to pulse the IR_led over 2 pulses

      if (frameCounterL != 1){

      PulseIRLED( 123, CX3_IR_LED_RIGHT);

      frameCounterL++;

      }

      else{

      frameCounterL = 0;

      IR_flag = CyFalse;

      }

      }

      else

      {

      if (frameCounterR != 1){

      PulseIRLED( 123, CX3_IR_LED_LEFT);

      frameCounterR++;

      }

      else{

      frameCounterR = 0;

      IR_flag = CyTrue;

      }

      }

      }

       

       

      // Pulse IRLED

      // ========================================================================================================

      void PulseIRLED( const uint16_t wPulseWidth, const uint8_t IRLED)

      {

      gpioIRComplexConfig.outValue = IR_LED_ENABLE;

      gpioIRComplexConfig.pinMode = CY_U3P_GPIO_MODE_PULSENOW;

      #ifdef TIME_IN_US

      gpioIRComplexConfig.threshold = CY_FX_PWM_PERIOD_MS / 1000 * wPulseWidth;

      #else

      gpioIRComplexConfig.threshold = CY_FX_PWM_PERIOD_MS * wPulseWidth;

      #endif // TIME_IN_US

      CyU3PGpioSetComplexConfig( IRLED, &gpioIRComplexConfig);

      CyU3PGpioComplexPulseNow( IRLED, gpioIRComplexConfig.threshold);

      } // PulseIRLED