Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

How to Get a 0.1-µs Unit Timestamp with FX3 – KBA220034

How to Get a 0.1-µs Unit Timestamp with FX3 – KBA220034

50 questions asked 10 questions asked 5 questions asked

How to Get a 0.1-µs Unit Timestamp with FX3 – KBA220034

Version: **

Translation - Japanese: FX3で0.1 µs単位のタイムスタンプを取得する方法 – KBA220034 - Community Translated (JA)


How to get 0.1-µs unit timestamp with FX3?


FX3 has a complex GPIO timer. To read the current timer value, use the CyU3PGpioComplexSampleNow API. As a result, it is possible to get 0.1-µs unit timestamp with the GPIO timer properly configured.

Assume the value of SYS_CLK_PLL is 403.2 MHz, a 0.1-µs unit timestamp needs the timer running at around 10 MHz frequency

1. Configure Fast GPIO Clock at approximately 10 MHz. Fast GPIO Clock is derived from SYS_CLK_PLL/4 with divider set as 10, so the frequency of Fast GPIO Clock is 10.08 MHz.
           CyU3PGpioClock_t gpioClock;
          /* Initialize the GPIO module */
         gpioClock.fastClkDiv = 10;
           gpioClock.slowClkDiv = 0;
           gpioClock.simpleDiv = CY_U3P_GPIO_SIMPLE_DIV_BY_2;
           gpioClock.clkSrc = CY_U3P_SYS_CLK_BY_4;
           gpioClock.halfDiv = 0;

          return CyU3PGpioInit(&gpioClock, NULL);

2. Configure DUMMY_COMPLEX_GPIO to be in static output mode.
          /* Configure DUMMY_COMPLEX_GPIO as static mode output*/
         gpioComplexConfig.outValue = CyFalse;
         gpioComplexConfig.inputEn = CyFalse;
         gpioComplexConfig.driveLowEn = CyTrue;
         gpioComplexConfig.driveHighEn = CyTrue;
         gpioComplexConfig.pinMode = CY_U3P_GPIO_MODE_STATIC;
         gpioComplexConfig.intrMode = CY_U3P_GPIO_INTR_TIMER_ZERO;
         gpioComplexConfig.timerMode = CY_U3P_GPIO_TIMER_HIGH_FREQ;
         gpioComplexConfig.timer = 0;
         gpioComplexConfig.period = 0xffffffff;
         gpioComplexConfig.threshold = 0xffffffff;
         status = CyU3PGpioSetComplexConfig(DUMMY_COMPLEX_GPIO, &gpioComplexConfig);
         if (status != CY_U3P_SUCCESS)
            CyU3PDebugPrint (4, "CyU3PGpioSetComplexConfig failed, error code= %d\n" ,status);

3. Use the CyU3PGpioComplexSampleNow API to get the timestamp.
      CyU3PGpioComplexSampleNow(DUMMY_COMPLEX_GPIO, &timestamp);