2 Replies Latest reply on Apr 27, 2020 9:27 PM by AlakanandaB_86

    accessing an isr static variable

    BeHi_4668916

      I have an application that is getting stuck when I try to access a static variable from within my isr.  The interrupt is working and at a periodic interval (1 millisecond) the isr is incrementing a static variable inside that file.  If I reference that variable directly in the sysTickDelay function there is no problem, BUT if I access it using a getSysTick function then my application gets stuck.  I've used this same technique before on other micros and it has worked, not sure what I am doing, or have configured differently here that it is not working on my PSoC4 application.

       

      Thanks.

       

       

      /* Variables

      -------------------------*/

      static uint32_t oneMsecTick = 0;

       

      /**

        * @brief  This function is called from the SysTick ISR every millisecond.

        *         It increments a variable to be used as a consistent time base.

        *

        * @param  None

        * @retval None

        */

      void sysTickIncrement( void )

      {

        oneMsecTick++;

      }

       

      /**

        * @brief  Provides access to SysTick variable value in milliseconds.

        *

        * @param  None

        * @retval Tick value

        */

      uint32_t getSysTick( void )

      {

        return ( oneMsecTick );

      }

       

      /**

        * @brief  Provides a blocking delay in millisecond.

        *

        *  * @param  delay_mSecs : specifies the delay time length, in milliseconds.

        * @retval None

        */

      void sysTickDelay( uint32_t delay_mSecs )

      {

        uint32_t timeDelay = getSysTick() + delay_mSecs;

       

        while( getSysTick() < timeDelay )

        {

      //    feedTheWatchDog();  /* Refresh the watchdog timer */

          uint32_t count = 0;

          count++;

        }

      }