7 Replies Latest reply on Jun 26, 2018 10:57 AM by rajivv_36

    Issue with variables used in interrupts that are NOT assigned volatile.


      I have a very short main.c that assigns a SysTick interrupt with a non-volatile assigned variable (uint32 systick = 0;) named systick that gets incremented every time the interrupt occurs.

      Simple.  Note:  Using Creator 4.2

      In main(), I compare the systick value for different values to make decisions.  The code 'hangs' looking for systick to get to 100.  (In debug mode, the code hangs yet the systick exceeds the value be checked)

      If I assign the systick as volatile (volatile uint32 systick =  0;), the code DOES NOT hang!


      I think the compiler is assuming the systick variable can be register assigned (nonvolatile) in main().  Yet when I hover over the systick var, it can far exceed the value being compared.


      Attached is a very small archive of the program that exhibits this issue.