Hi again David, I just tried this and it seems as though the method I used is OK. In MPLAB, I set the zero bit in STATUS and then executed a MOVF STATUS,W. The zero bit was clear in STATUS after the MOVF but the W register held the unmodified value of STATUS. Do you see any further problems with it? Incidentally, is there a way in MPLAB to force the unwritable bits of STATUS (TO and PD) to particular values? That is, can we simulate a WDT timeout or wakeup from SLEEP without having to actually place code in the file to cause those events? Thanks again, Sean At 04:31 PM 1/12/2003 +1000, you wrote: >Hi Sean, >I took a really quick peek at the code and noticed that your ISR >save and restore possibly has a bug in it. When you get the >status register, you are affecting the zero flag just by reading it >whereas a swap doesn't. I would have thought that the status bits >would not change until *after* the MOVF instruction in which case >STATUS gets cleared anyway in the next line but Microchip seem >to recommend doing it the following way: (Taken from my code) > > org 4 ;interrupt vector > movwf save_w ;save contents of working register > swapf status,w ;get current status into w > clrf status ;clear all status & ram bank bits > movwf save_s ;and save it for interrupt restore > movf pclath,w ;get current code page address > movwf save_p ;and save it for interrupt restore > clrf pclath ;select code page 0 > movf fsr,w ;get current fsr position > movwf save_f ;and save it for interrupt restore > ... > ... > ... > movf save_f,w ;get saved fsr > movwf fsr ;& restore it > movf save_p,w ;get the previous code bank > movwf pclath ;and restore it > swapf save_s,w ;get back the status bits > movwf status ;put into the status register > swapf save_w,f ;swap the high and low nibbles > swapf save_w,w ;of the saved w register back into w reg > retfie ;then return from interrupt > >BTW, I like the clock. It's nice to make something that you use everyday. >I made a simple shower/game timer for my kids one day over Christmas. >They use it all the time. http://www.users.on.net/avd/pic/index.html >David... > >-- >http://www.piclist.com hint: PICList Posts must start with ONE topic: >[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads