7 Replies Latest reply on Jun 22, 2020 4:19 AM by JayakrishnaT_76

    CX3: How to set tick rate to 1 microsecond

    GaK_4661021

      Hi,

       

      How can I set the tick rate to 1 microsecond? I have found one API CyU3PSetTime() to set tick rate but I don't know how can I use it to set 1-microsecond tick rate.

       

      Can anyone please help here?

        • 1. Re: CX3: How to set tick rate to 1 microsecond
          JayakrishnaT_76

          Hello,

           

          Please refer to the following KBA which describes how to change timer tick.

          EZ-USB® FX3™ Timer Ticks – KBA93074

           

          From the KBA, it is not possible to change the tick rate to 1-micro seconds. Please let me know what exactly is your need by changing it to 1 micro second. Is it to introduce a small delay?

          If your requirement is to add a small delay (of microseconds), then please use the API CyU3PBusyWait(). You can refer to FX3 API Guide to understand more about this API.

           

          Best Regards,

          Jayakrishna

          • 2. Re: CX3: How to set tick rate to 1 microsecond
            GaK_4661021

            My requirement is to measure input pulse on-time using CX3 firmware(I am configuring one GPIO as an input). And the minimum resolution we require is 100 microseconds. It means we may get a minimum of 100 microseconds on-time pulse on that particular GPIO.

            • 3. Re: CX3: How to set tick rate to 1 microsecond
              JayakrishnaT_76

              Hello,

               

              Please let me know if you are using a simple or a complex GPIO in your application. Also, according to the present implementation, how are you checking the time upto which the GPIO stays LOW.

               

              Best Regards,

              Jayakrishna

              • 4. Re: CX3: How to set tick rate to 1 microsecond
                GaK_4661021

                I am using GPIO19 which is complex GPIO as per my knowledge. Currently, we are unable to check for 100 microseconds pulse.

                • 5. Re: CX3: How to set tick rate to 1 microsecond
                  JayakrishnaT_76

                  Hello,

                   

                  Please let me know how you are tracking the time for which the GPIO stays low now. Please share the snippets of that section of the code so that I can understand more on the issue. Also, as per the present implementation, what is the smallest time that you are able to detect?

                   

                  Best Regards,

                  Jayakrishna

                  • 6. Re: CX3: How to set tick rate to 1 microsecond
                    GaK_4661021

                    Below is the code snippets of GPIO interrupt callback in which I am tracking pulse high time.

                     

                    void CyFxGpioIntrCb (

                            uint8_t gpioId /* Indicates the pin that triggered the interrupt */

                            )

                    {

                        CyBool_t gpioValue = CyFalse;

                        CyU3PReturnStatus_t apiRetStatus = CY_U3P_SUCCESS;

                        unsigned long RisingEdgeTime = 0;

                        unsigned long FallingEdgeTime = 0;

                     

                        /* Get the status of the pin */

                         apiRetStatus = CyU3PGpioGetValue (gpioId, &gpioValue);

                         if (apiRetStatus == CY_U3P_SUCCESS)

                         {

                              /* Check status of the pin */

                              if (gpioValue == CyTrue)

                              {

                                   RisingEdgeTime = CyU3PGetTime();

                              }

                              else

                              {

                                   FallingEdgeTime = CyU3PGetTime();

                                   CyU3PDebugPrint (4, "Pulse high time time = %u\n", FallingEdgeTime - RisingEdgeTime);

                                   FallingEdgeTime = 0;

                                   RisingEdgeTime = 0;

                              }

                         }

                    }

                    • 7. Re: CX3: How to set tick rate to 1 microsecond
                      JayakrishnaT_76

                      Hello,

                       

                      Please try the following steps:

                      1. Use a simple GPIO which is used to identify the state of the input signal.

                      2. Use another complex GPIO which is configured as a timer.

                      3. The API CyU3PGpioComplexSampleNow() can be used to sample the value of the timer at an instant.

                       

                      Please refer to the following KBA to understand how to configure a complex GPIO for this requirement.

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

                       

                      Also, I have created a sample project by modifying the SDK example GpioApp for your requirement. Please refer to the same and implement the same in your project. While implementing the same in your project, make sure that you do not use GPIOs that are used for other purposes. Please let us know if you face any issue while measuring the time after implementing this.

                       

                      Best Regards,

                      Jayakrishna