2 Replies Latest reply on Dec 13, 2018 5:53 AM by xihoc_3044746

    How to generate clock pulse on fx3

    xihoc_3044746

      I'm using CYUSB3KIT-003 test uvc with a camera sensor. But compared with CYUSB3ACC-004 Aptina Image Sensor, there is no crystal on my camera. So, I need to generate 24Mhz clock (xclk) for it.

       

      Code is based on an75779 (FX3 uvc demo). The following is my modifiations:

       

      uvc.c:CyFxUVCApplnInit()

       

      /* Init the GPIO module */
      gpioClock.fastClkDiv = 2;
      gpioClock.slowClkDiv = 2;
      gpioClock.simpleDiv  = CY_U3P_GPIO_SIMPLE_DIV_BY_2;
      gpioClock.clkSrc     = CY_U3P_SYS_CLK;
      gpioClock.halfDiv    = 0;
      
      ............
      
      apiRetStatus = CyU3PGpioSetSimpleConfig (SENSOR_RESET_GPIO, &gpioConfig);
      
      // I add the for 24Mhz output
      /* SENSOR_RESET_GPIO is the Sensor reset pin */
      CyU3PGpioComplexConfig_t gpioXclkConfig;
      gpioXclkConfig.outValue = CyTrue;
      gpioXclkConfig.driveLowEn = CyFalse;
      gpioXclkConfig.driveHighEn = CyFalse;
      gpioXclkConfig.inputEn = CyFalse;
      gpioXclkConfig.pinMode = CY_U3P_GPIO_MODE_PULSE_NOW;
      gpioXclkConfig.intrMode = CY_U3P_GPIO_NO_INTR;
      gpioXclkConfig.timerMode = CY_U3P_GPIO_TIMER_HIGH_FREQ;
      gpioXclkConfig.timer = 0; // Timer initial value.
      // Load the period to the maximum value so that the count is not reset.
      gpioXclkConfig.period = 0xFFFFFFFF; // Timer period.
      gpioXclkConfig.threshold = 0; // Timer threshold value.
      apiRetStatus           = CyU3PGpioSetComplexConfig (SENSOR_XCLK_GPIO, &gpioXclkConfig);
      if (apiRetStatus != CY_U3P_SUCCESS)
      {
          CyU3PDebugPrint (4, "GPIO Set Config Error, SENSOR_XCLK_GPIO, Error Code = %d\n", apiRetStatus);
          CyFxAppErrorHandler (apiRetStatus);
      }
      apiRetStatus           = CyU3PGpioComplexPulseNow (SENSOR_XCLK_GPIO, 0xFFFFFFFF);
      if (apiRetStatus != CY_U3P_SUCCESS)
      {
          CyU3PDebugPrint (4, "GPIO CyU3PGpioComplexPulseNow Error, SENSOR_XCLK_GPIO, Error Code = %d\n", apiRetStatus);
          CyFxAppErrorHandler (apiRetStatus);
      }
      
      
      

       

      #define SENSOR_XCLK_GPIO     24

       

      Leaving all other code unchanged.

       

      My debug uart get there outputs:

       

      GPIO CyU3PGpioComplexPulseNow Error, SENSOR_XCLK_GPIO, Error Code = 70

       

      I don't know for Error Code = 70 (CY_U3P_ERROR_NOT_SUPPORTED). and I can't found any examples for calling CyU3PGpioComplexPulseNow in google ( The funcation may not be for what I need).

       

      I read cyu3gpiocomplex.c:CyU3PGpioComplexPulseNow and there are 2 lines return CY_U3P_ERROR_NOT_SUPPORTED.

       

      Please help me how to output a 24Mhz clock.

       

       

      thanks~

        • 1. Re: How to generate clock pulse on fx3
          YiZ_31

          Hi,

           

          Pin 24 cannot be configured as complex GPIOs. You can find relating information in  section 3.6.5 of programmer's manual.

           

          If you want to generate a 24MHz clock, the recommend setting for the GPIO is:

           

              gpioConfig.outValue = CyFalse;

              gpioConfig.inputEn = CyFalse;

              gpioConfig.driveLowEn = CyTrue;

              gpioConfig.driveHighEn = CyTrue;

              gpioConfig.pinMode = CY_U3P_GPIO_MODE_PWM;

              gpioConfig.intrMode = CY_U3P_GPIO_NO_INTR;

              gpioConfig.timerMode = CY_U3P_GPIO_TIMER_HIGH_FREQ;

              gpioConfig.timer = 0;

              gpioConfig.period = 7;

              gpioConfig.threshold = 4;

           

          If you want to know how to calculate the period, you can refer to this page:

          generating pwm on fx3

           

          Regards,

          Eddie

          • 2. Re: How to generate clock pulse on fx3
            xihoc_3044746

            thanks for your reply. I'll try today.