AnsweredAssumed Answered

Program execution stops when a variable is declared in IRQ handler

Question asked by sc0re.Over on Dec 6, 2016
Latest reply on Dec 8, 2016 by FTITI.Walid


I've come across this strange problem where I can't seem to find a reasonable explanation why it occurs:

I am using a simple RTOS, I have an EXTI interrupt handler that calls a simple function which sets a flag and returns.

If I declare a local int variable inside that function, the program execution stops. It does not hardfault, it just stops. OS scheduler does not work anymore, the code actually never returns from the function, everything freezes until watchdog kicks in.


Irq handler is very simple:

void EXTI9_5_IRQHandler(void)
debug("XTI9_5 handler\n");

The function as well:

void xSensor_IRQ_callback()
   u32 status = xSensor_geStatus();
   if ((status & XS_MSTAT_IRQSRC) == XS_IRQSRC_RX)
      rx_len = status >> 8;
      debug("RX %d\n", rx_len);
   } else



The code above never returns. As soon as I declare status variable globally, everything works. 


If I don't store the result of xSensor_getStatus() in a variable and call the function whenever it is needed, the code also works as it should. As soon as I add a simple declatation such as

u32 status = 1234;

which is not used anywhere below, the program stops again. 

Any suggestions what may be leading to such behavior or where should I look into would be warmly welcome.