3 Replies Latest reply on Oct 25, 2019 6:26 AM by KandlaguntaR_36

    Using a complex GPIO timer to generate interrupts

    JuCh_3556216

      Hi,

       

      I'm trying to use a complex GPIO configured as shown here to generate an interrupt after reaching a pre-set time. There are plenty of examples on how to use simple and complex GPIO to generate interupts based on pin inputs, but I haven't found anything that illustrates how to generate interrupt flags based on a simple timer/counter. Ultimately, I'm trying to use a complex GPIO timer to let the processor know when a certain delay has elapsed. The delay is on the order of microseconds, so CyU3PBusyWait() is inadequate. I'm comfortable using direct register reads/writes to achieve this. In addition to setting up and generating interrupts, it would be helpful to know how to properly reset the timer register.

       

      I also found this thread stating that generating interrupts does not work when using complex GPIO. Is this still the case?

       

      Thanks

        • 1. Re: Using a complex GPIO timer to generate interrupts
          KandlaguntaR_36

          Hello,

           

          Can you please post the code snippet that you have tried on your side?

           

          Sridhar

          • 2. Re: Using a complex GPIO timer to generate interrupts
            JuCh_3556216

            Hi Sridhar,

             

            We've tried may ways of implementing a timer, but we're unsure as to what the correct procedure is. The code we're working with can be found here.The following code snippets may not make sense since the configuration is intertwined with our application. The functions of inteterest are:

             

            • AdiAppStart() - where the complex GPIO is configured as a timer.
                CyU3PGpioComplexConfig_t gpioComplexConfig;
                CyU3PMemSet ((uint8_t *)&gpioComplexConfig, 0, sizeof (gpioComplexConfig));
                gpioComplexConfig.outValue = CyFalse;
                gpioComplexConfig.inputEn = CyFalse;
                gpioComplexConfig.driveLowEn = CyTrue;
                gpioComplexConfig.driveHighEn = CyTrue;
                gpioComplexConfig.pinMode = CY_U3P_GPIO_MODE_STATIC;
                gpioComplexConfig.intrMode = CY_U3P_GPIO_NO_INTR;
                gpioComplexConfig.timerMode = CY_U3P_GPIO_TIMER_HIGH_FREQ;
                gpioComplexConfig.timer = 0;
                gpioComplexConfig.period = 0xFFFFFFFF;
                gpioComplexConfig.threshold = 0xFFFFFFFF;
                status = CyU3PGpioSetComplexConfig(ADI_TIMER_PIN, &gpioComplexConfig);
            

             

            • AdiDataStream_Entry() - where the timer is implemented.
            //Transmit first word without reading back
                            tempData[0] = regList[0];
                            tempData[1] = regList[1];
                            CyU3PSpiTransmitWords(tempData, 2);
            
                            //Set the pin timer to 0
                            GPIO->lpp_gpio_pin[ADI_TIMER_PIN_INDEX].status &= ~CY_U3P_LPP_GPIO_ENABLE;
                            GPIO->lpp_gpio_pin[ADI_TIMER_PIN_INDEX].period = 100000;
                            GPIO->lpp_gpio_pin[ADI_TIMER_PIN_INDEX].status |= CY_U3P_LPP_GPIO_ENABLE;
            
                            //Read the registers in the register list into regList
                            for(regIndex = 0; regIndex < (bytesPerBuffer - 1); regIndex += 2)
                            {
                                //Wait for the complex GPIO timer to reach the stall time
                                timerVal = 0;
                                while(timerVal < stallTime)
                                {
                                    //Set the pin config for sample now mode
                                    GPIO->lpp_gpio_pin[ADI_TIMER_PIN_INDEX].status = (timerPinConfig | (CY_U3P_GPIO_MODE_STATIC << CY_U3P_LPP_GPIO_MODE_POS));
                                    //wait for sample to finish
                                    while (GPIO->lpp_gpio_pin[ADI_TIMER_PIN_INDEX].status & CY_U3P_LPP_GPIO_MODE_MASK);
                                    //read timer value
                                    timerVal = GPIO->lpp_gpio_pin[ADI_TIMER_PIN_INDEX].timer;
                                }
            
                                CyU3PDebugPrint (4, "val = %d\r\n", timerVal);
            
            
            • 3. Re: Using a complex GPIO timer to generate interrupts
              KandlaguntaR_36

              Hello,

               

              Please find the attached modified ComplexGpio example project.

               

              I can see that the complex interrupt is generated on GPIO 51.

              Note that 50 and 51 to be shorted.

               

              Please collect the UART logs which display the log for complex interrupt.

               

              As of now, the interrupt is generated only once when the timer value equals to Threshold.

               

              We need to do further changes in order to make to work at lower intervals (in the order of us) and continuously.

               

              And also we need to find out the resetting the timer.

               

              Regards,

              Sridhar