3 Replies Latest reply on Mar 7, 2017 2:48 AM by user_1377889

    Timer configuration

    ambarish.bh_1555891

      Hi Cypress Team, 

         

      I want to configure timer in my project with 1 Micro second .

         

      i used timer function block , set the clk at 2 MHz and count is 2, so it is showing 1us .

         

      but i want to reconfigure timer in my state machine many times with different time configuration (1,3,20us and 125us).

         

      so in the ISR , written code   

         

         CY_ISR(Timer_ISR)
      {
          Timer_ISR_ClearPending();

         

       //Timer_1ms_ClearFIFO();

         

      BottomTemperatureControl();

         

      }

         

      void BottomTemperatureControl(void)

         

      {

         

      //here am calling reload timer function with different timer time configuration.

         

      ReloadTimer(Number of us timer configuration); 

         

      }

         

       

         

      void ReloadTimer(int nTimerInMicroSeconds)
      {
        Timer_1ms_Stop();
          nTimerInMicroSeconds = nTimerInMicroSeconds * 2;
         Timer_1ms_WritePeriod(nTimerInMicroSeconds);
          Timer_1ms_Start();
         
      }

         

      if i want to set 3us timer, then i will pass 3 to the reloadTimer function and calculate the period count value inside the reload functon.

         

      for 2 counts, 1us timer 

         

      for 3 us, 2*3 = Count value(6).

         

      if high set this value for 100us ,50us its working fine but for 3us timer , getting 40us pulse.

         

       

         

      kindly help me in this.

         

      I am not able to configure 16, 24 ,32 bit resolution for  the attached  timer function block .

         

      it is showing error if I select 16,24 bit resolution.

         

      please find the attached images for timer configuration.