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:
The function as well:
u32 status = xSensor_geStatus();
if ((status & XS_MSTAT_IRQSRC) == XS_IRQSRC_RX)
rx_len = status >> 8;
debug("RX %d\n", rx_len);
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.