On Sun, Sep 02, 2001 at 07:31:59PM -0400, Brandon Fosdick wrote: [...] > > I was trying to use the following function I found on piclist.org > > two2n > andlw 0x07 > addwf PCL, f > retlw 0x01 > retlw 0x02 > retlw 0x04 > retlw 0x08 > retlw 0x10 > retlw 0x20 > retlw 0x40 > retlw 0x80 > > Nothing complicated. But I've found that if I use the SPI module a > certain number of times before calling that function, the PIC will > reset. Eventually I got the number pegged at 18, that is, send/receive > 18 bytes over the SPI port, then do anything that involves modifying PCL > and the chip will reset. Sometimes, at around 12 bytes, the chip will > start executing random instructions, but won't fully reset. > > So I thought I had found the two magic numbers to avoid. To my suprise, > I found that if I change the number of instructions between the SPI > calls and the PCL modifying instructions, the magic numbers change. > Fewer instructions, more calls to SPI, and vice-versa. [...] Are you sure, that your "two2n" does not cross the page boundary? Read: http://www.piclist.com/techref/microchip/tables.htm http://www.piclist.com/techref/microchip/pages.htm to get more detailed info. -- HTH & Regards, Wojciech M. Zabolotny http://www.ise.pw.edu.pl/~wzab <--> wzab@ise.pw.edu.pl http://www.debian.org Use Linux - an OS without "trojan horses" inside -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu