Jim Main wrote: > >PCLATH is NOT a readable Register (it's just writeable). So instead of > >reading it and saving it, you should save the value you are programming in, > >into "temp_lath" when PCLATH is being changed. > > Would this always work - say I change pclath and store it in temp_lath at > the same time, then I cross a page boundary in the code before the interrupt > occurs - wouldn't the restored pclath cause a jump backwards after the > interrupt's finished?? Forget about PCLATH being write-only - it is readable and writable, but it is NOT the high byte of the PC. Basically, if you use PCLATH in the interrupt routine, you must save and restore it. If you do ANY gotos or calls in your interrupt routine, and you are using more than 1 page of ROM (2K words on the 14 bit PICS) then you must save PCLATH, then load it with the high byte of your current address (usually 0 for interrupt routines, since they start at location 4). The actual saved PC from where the interrupt occurred is on the stack, and is NOT affected by PCLATH. When you do the RETFIE at the end of the interrupt routine, the entire PC will be restored from the stack. But you must treat the processor like a national park - leave it like you found it, including PCLATH. Of course if you are using a 14-bit PIC with 2K words of ROM or less, then you can ignore PCLATH unless you do computed gotos (addwf PCL). Clyde -- Clyde Smith-Stubbs | HI-TECH Software, | Voice: +61 7 3300 5011 clyde@hitech.com.au | P.O. Box 103, Alderley, | Fax: +61 7 3300 5246 http://www.hitech.com.au | QLD, 4051, AUSTRALIA. | BBS: +61 7 3300 5235 ---------------------------------------------------------------------------- For info on the World's best C cross compilers for embedded systems, point your WWW browser at http://www.hitech.com.au, or email info@hitech.com.au