Hi, SWAPF is used as that does not affect any of the STATUS bits, (MOVF would change Z flag...) For realtime clock you can see examples at piclist techref library: http://www.piclist.com/techref/microchip/time.htm Regards, Tamas ---------- Forwarded message ---------- From: KPL Date: Jun 13, 2007 10:12 AM Subject: pic clock interrupt To: "Microcontroller discussion list - Public." Hi, I am thinking about controller for hydroponic greenhouse, so I need real time clock. I am looking thru several examples that I can find on web, and have found this code: http://www.bobblick.com/techref/projects/propclock/mclock8.asm Question is - why the original author is swapping nibbles, when saving STATUS byte, in interrupt routine? It is reswapped back again, when restoring. ;-------- ; INTERRUPT SERVICE ROUTINE ;-------- org 0x04 ;interrupt vector Intsvc movwf safe_w ;save w swapf STATUS,w ;swap status, w movwf safe_s ;save status(nibble swap, remember) ;-------- ; done saving, now start working ;-------- ;-------- ; done working, start restoring ;-------- swapf safe_s,w ;fetch status, reswap nibbles movwf STATUS ;restore status swapf safe_w,f ;swap nibbles in preparation swapf safe_w,w ;for the swap restoration of w bcf INTCON,2 ;clear interrupt flag before return retfie ;return from interrupt Anybody knows some good (well commented :) real time clock sources to look thru? -- KPL -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist