2 Replies Latest reply on Jan 11, 2018 11:29 PM by leo83616_3006676

    About FX3 GPIO speed problem

    leo83616_3006676

      Hello, everyone

      How do I set the FX3 frequency to 400Mhz correctly?

      Because I now test GPIO for pure output of 0 and 1, I see 459.39Khz on my oscilloscope.

      Here is my FX3 firmware:

       

      BulkLpAppThread_Entry():

       

      void BulkLpAppThread_Entry ( uint32_t input) 
      {
      
          CyU3PGpioClock_t gpioClock;
          gpioClock.fastClkDiv = 2;
          gpioClock.slowClkDiv = 0;
          gpioClock.simpleDiv  = CY_U3P_GPIO_SIMPLE_DIV_BY_2;
          gpioClock.clkSrc     = CY_U3P_SYS_CLK;
          gpioClock.halfDiv    = 0;
          CyU3PGpioInit(&gpioClock, NULL);
      
          CyU3PGpioSimpleConfig_t gpioConfig;
          gpioConfig.outValue    = CyTrue; 
          gpioConfig.inputEn     = CyFalse; 
          gpioConfig.driveLowEn  = CyTrue; 
          gpioConfig.driveHighEn = CyTrue; 
          gpioConfig.intrMode    = CY_U3P_GPIO_NO_INTR;
          CyU3PGpioSetSimpleConfig(45, &gpioConfig); 
      
         for (;;){
             CyU3PGpioSetValue (45,CyFalse);
             CyU3PGpioSetValue (45,CyTrue);
          }
      }
      

       

      CyFxApplicationDefine ();

      void CyFxApplicationDefine (void) 
      {
          void *ptr = NULL;
          uint32_t retThrdCreate = CY_U3P_SUCCESS;
      
          ptr = CyU3PMemAlloc (CY_FX_BULKLP_THREAD_STACK);
      
          retThrdCreate = CyU3PThreadCreate (&BulkLpAppThread,          
                               "21:Bulk_loop_AUTO",                     
                                BulkLpAppThread_Entry,                  
                                0,                                      
                                ptr,                                    
                                CY_FX_BULKLP_THREAD_STACK,               
                                CY_FX_BULKLP_THREAD_PRIORITY,           
                                CY_FX_BULKLP_THREAD_PRIORITY,           
                                CYU3P_NO_TIME_SLICE,                   
                                CYU3P_AUTO_START                        
                                );
      
      
          if (retThrdCreate != 0)
          {
              while(1);
          }
      }
      

       

      main():

      int main (void){ //1
          CyU3PReturnStatus_t status = CY_U3P_SUCCESS;
      
      
          CyU3PSysClockConfig_t CONFIG_CLOCK;
      
          CONFIG_CLOCK.setSysClk400 = CyTrue;
          CONFIG_CLOCK.cpuClkDiv = 2;
          CONFIG_CLOCK.dmaClkDiv = 2; 
          CONFIG_CLOCK.mmioClkDiv = 2; 
          CONFIG_CLOCK.useStandbyClk = CyFalse; 
          CONFIG_CLOCK.clkSrc = CY_U3P_SYS_CLK;
      
          status = CyU3PDeviceInit (&CONFIG_CLOCK);
      
          if (status != CY_U3P_SUCCESS)
          {
              goto handle_fatal_error;
          }
          status = CyU3PDeviceCacheControl (CyTrue, CyTrue, CyFalse);
          if (status != CY_U3P_SUCCESS)
          {
              goto handle_fatal_error;
          }
      
      
          CyU3PIoMatrixConfig_t io_cfg;
      
          CyU3PMemSet ((uint8_t *)&io_cfg, 0, sizeof(io_cfg));
             io_cfg.isDQ32Bit = CyFalse;
             io_cfg.s0Mode = CY_U3P_SPORT_INACTIVE;
             io_cfg.s1Mode = CY_U3P_SPORT_INACTIVE;
             io_cfg.useUart   = CyFalse;
             io_cfg.useI2C    = CyFalse;
             io_cfg.useI2S    = CyFalse;
             io_cfg.useSpi    = CyFalse;
             io_cfg.lppMode   = CY_U3P_IO_MATRIX_LPP_DEFAULT;
      
             io_cfg.gpioSimpleEn[0]  = 0x00000000; //0~31
             io_cfg.gpioSimpleEn[1]  = 0x00002000; //45 on
             io_cfg.gpioComplexEn[0] = 0;
             io_cfg.gpioComplexEn[1] = 0;
      
          status = CyU3PDeviceConfigureIOMatrix (&io_cfg);
          if (status != CY_U3P_SUCCESS)
          {
              goto handle_fatal_error;
          }
          CyU3PKernelEntry ();
          return 0;
      handle_fatal_error:
          while (1);
      }
      

       

       

      Am I missing something set?