1 Reply Latest reply on Jul 19, 2020 11:07 PM by YiZ_31

    Fx3 / CX3,How to realize  timer interrupt?

    YaXi_4492421

      I want to achieve an interrupt timer, how to achieve it?

      I have seen from the data that it can be implemented by GPIO interrupt, but it can't generate interrupt. Here is my code:

      //Initialization code:

      CyU3PGpioClock_ t gpioClock;

      CyU3PGpioComplexConfig_ t gpioConfig;

      CyU3PReturnStatus_ t apiRetStatus = CY_ U3P_ SUCCESS;

      /* Init the GPIO module */

      1. gpioClock.fastClkDiv = 2;
      2. gpioClock.slowClkDiv = 0;
      3. gpioClock.simpleDiv = CY_ U3P_ GPIO_ SIMPLE_ DIV_ BY_ 2;
      4. gpioClock.clkSrc = CY_ U3P_ SYS_ CLK;
      5. gpioClock.halfDiv = 0;

      apiRetStatus = CyU3PGpioInit(&gpioClock, CyFxGpioIntrCb);

      CyU3PGpioComplexConfig_ t gpioComplexConfig;

      1. gpioComplexConfig.outValue = CyFalse;
      2. gpioComplexConfig.inputEn = CyTrue;
      3. gpioComplexConfig.driveLowEn = CyFalse;
      4. gpioComplexConfig.driveHighEn = CyFalse;
      5. gpioComplexConfig.pinMode = CY_ U3P_ GPIO_ MODE_ STATIC;
      6. gpioComplexConfig.intrMode = CY_ U3P_ GPIO_ INTR_ TIMER_ THRES;
      7. gpioComplexConfig.timerMode = CY_ U3P_ GPIO_ TIMER_ POS_ EDGE;
      8. gpioComplexConfig.timer = 0;
      9. gpioComplexConfig.period = 0x00000001; // Reset after each interrupt
      10. gpioComplexConfig.threshold = 0x00000001; //Generate interrupt every 125us

      apiRetStatus = CyU3PGpioSetComplexConfig(GPIO_ TIMER, &gpioComplexConfig);

      if (apiRetStatus != CY_ U3P_ SUCCESS)

      {

      vJackyTestPrintErr("CyU3PGpioSetComplexConfig failed: %d\n",apiRetStatus);

      }

      /*****************************************************/

      //Interrupt callback function:

      /****************************************************/

      void CyFxGpioIntrCb (

      uint8_ t gpioId /* Indicates the pin that triggered the interrupt */

      )

      {

      if(GPIO_ TIMER == gpioId)

      {

      dwTimeCountNow++;

      if(dwTimeCountNow>TIME_ COUNT_ MAX)

      {

      dwTimeCountNow = 0;

      }

      }

      }

      /*******************************************/

      //How can timer interrupt be generated? If GPIO can interrupt timer, is there a problem with my code?

        //I'm looking forward to the teacher's reply