Hello All,

Maybe someone could advise what are most common mistakes in building a program driven by interrupts. I am playing with PIC18f24k22 which should have big enough stack but so far my attempts to use INT0...INT3 did not have much success as I always stick into stack overflow reset. Checked if all my gosubs end with returns and it looks like they do. Global int bit is also set and flags cleared but as soon as I enable INTS and press button causing external INT, stack overflows. The code is pretty large to post here but maybe someone could advise what to read about common mistakes on this topic. Does it make sense that I use Long variables? I tried to comment pieces of code and it looks like at some point when it becodes critically large the problem appears... Must say I have many subroutines but the problem often appears when the executing piece of code not too deep in them and often when no subs surrently running

Must say I felt more comfortable with PIC16 which have circled stack so if a leakage like exiting a subroutine without "return" occurs, it does not make any problem. It looks like it is a different story with PIC18

Thank you!