On Thu, 12 Mar 1998 13:47:06 -0400 "Stevenson, Brad" writes: >I don't think you can do this on a PIC because there is only one >interrupt vector. You could do this on a Motorola (for example), but >even then, I wouldn't recomend it. Getting interrupted from an >interrupt >can cause all kinds of problems (stack, endless loops, memory >corruption, etc). Recursive interrupt functions are a nightmare. I agree that interrupts interrupting interrupts should be discouraged. I don't think there's a problem with the single vector though. When an interrupt is generated, you just poll the various devices that are capable of generating the interrupt, then go deal with it. The multiple vector interrupt mechanisms just save you from having to do the polling. I recall a trick of using a binary encoder that is "dropped on the bus" when the interrupt vector address is called on single interrupt processors. The encoder then provided a number that the processor "thought" was the interrupt vector, so it jumped to it. At that address was a JMP instruction to the ISR. Seems to me that the real problem with nested interrupts on the PIC is lack of stack space for return adddresses and the lack of stack access for data. You have to save registers when the interrupt is called (if the interrupt uses those registers). With the PIC, these are typically stored in fixed RAM locations. A second interrupt would overwrite the first entries, messing up the return from the first interrupt. My early programming was on the 6800 or 6802 (in fact, I spent the morning modifying 6802 code to deal with year 2000). It had two interrupts: IRQ and NMI. Both pushed all registers on the stack. It was interesting to me when the 6809 came out. It had a "fast IRQ" that, as I recall, pushed only the flags and the return address. It was up to the user to push anything else on the stack. Always seemed to me that the number of cycles necessary to get the push instruction and actually do the push for even a couple registers would be more than just automatically pushing them all. Never ended up doing any 6809 stuff though. So... yes, you can do nested interrupts on the PIC by enabling the GIE flag inside the ISR. But... it's gonna be rough! Harold _____________________________________________________________________ You don't need to buy Internet access to use free Internet e-mail. Get completely free e-mail from Juno at http://www.juno.com Or call Juno at (800) 654-JUNO [654-5866]