Hello dear colleagues developers,
Let me first describe my situation:
in my code I have several things going on:
1. There is an infinite while loop located in my main() function... after HW and interrupt initialization, execution enters the loop and remains there where it outputs some data on the LCD. (roughly 10 times per second, I use delay for this).
2. In the same time I have two interrupts running. One is General purpose timer interrupt (which is scanning the keyboard and doing some other small stuff) executed every 100 ms. Other interrupt is int1_isr which is triggered by external ECG daughterboard (reading of SPI, filtering etc...)
After random time (sometimes 20 minutes, sometimes it only takes a couple of seconds) one of the following occurs:
- program counter somehow exits the while loop in the main. Two interrupts remain to execute properly. I have valid data coming from ECG board, and I have control over keyboard from the other interrupt...... or
- GPT timer gets disabled on its own, while loop is still executed but I loose keyboard which is scanned in the timer interrupt. As I can see Interrupt register IER0 gets overwritten somehow, but since that is CPU register and not located in the memory how is that possible? Can the code overwrite that register by writing to some memory location?
Could anyone explain what could be the cause of this strange behavior? I was thinking that somehow stack gets corrupted so I tried debugging using the methods described here but couldn't find anything suspicious. Funny thing is that only one part of the code gets corrupted, while other remain to execute properly.
I'm not using DSP/BIOS.
Please help, this is driving me nuts!