Hi, I'm working on a project with the PIC18F8525 using the mcc18 compiler. There seem to be some weird behaviours when using code in interrupts mixed with code running in the mainline. It seems that there is some sort of interference between variables running in the interrupt vs. variables in the mainline. Sometimes apparently innocent variables in either routine (like an index variable in a for loop) get clobbered. Only high priority interrupts are in use, so from what I've read that means that the appropriate registers get backed up automatically. The compiler seems to add some more code to back up other variables too. But stuff happens that shouldn't. By rearranging which parts run in the interrupt, I can affect what parts of my program get messed up, but I can't really explain what's happening very well. If I run everything in the interrupt or the mainline it all seems to work fine. But this is not good for my application which needs to do some things on an accurate time and some other more intensive procedures in the background. Another related question.... is it safe to modify variables from an interrupt that are being used in the mainline? Is there any point at which an undesired value could exist in the register? My interrupt runs a matrix keyboard/LED scanning routine on a timer so that the LEDs are multiplexed properly. The keyboard data is read in the interrupt and processed (for debouncing, etc.) in the mainline. But this sometimes causes erroneous behaviour. Any help would be greatly appreciated. My mind is so wrapped up in this that I might be forgetting to explain everything... Please ask and I would be glad for your help. Andrew -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist