I guess I answered my own question on this one. W15 is the stack pointer. By initializing this to 0 the chip always resets. > Another question. Why do they leave out W15? I have been trying to get > external INT0 working on this chip. > All associated regs set correctly etc., but when the interrupt occurs, > the PIC goes to the reset vector. The docs say that > any modification of an uninitialized W reg will cause a reset. Well > the docs also say that the interrupt handler uses W15 as > part of the context save. Should the below code be modified to include > W15? >> W0 thru W15 are memory locations 0..31. >> >> The above loop clears the memory locations associated with W1 thru W13 >> >> How, you ask? >> >> CLR W0 W0<-0 >> MOV W0,W14 W14<-0 >> REPEAT #12 Repeat next instruction 13! times >> MOV W0,[++W14] Does the following: >> Adds 2 to W14 >> Moves W0 (which is zero) to the memory location pointed to by W14 >> CLR W14 W14<-0 >> >> >> --- Bob Ammerman >> RAm Systems >> >> >> >> >>> It prevents buggy code from generating an uninitialized W register >>> reset, which is caused by using an uninitialized W register as an >>> address. This code pretty much defeats the whole point of the >>> uninitialized W register reset feature. >>> >>> -- >>> John W. Temples, III >>> >>> >> But this is only doing something to W0 and W14...or am I wrong? I'm >> really trying to >> get my head around this! >> >> > > > -- > Regards, > Stephen D. Barnes > -- Regards, Stephen D. Barnes -- Regards, Stephen D. Barnes -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist