>Dear Piclist, >Can anyone give me some pointers to using the RTCC interrupt on the >16C84? >This is how I've got it set up so far. > > > > >start bcf GLOBAL_INTERRUPT ; disable interrupts > >; for a 2.4576MHz crystal, 2457600/256=9600 >; load rtcc with 96 giving 100 interrupts/sec The crystal frequency is divided by four to generate the clock for TMR0, at that frequency I would load TMR0 with 32 to get 100 interrupts/second. 2.4576/4=614.4 614.4/256=2.4 2.4K/100=24 256-24=232=E8H >service movwf save_w > movf status,w > movwf save_s Use SWAPF intsruction. It won't affect the ZERO flag as does MOVF ISR movwf W_BACKUP ; swapf STATUS,W movwf STATUS_BACKUP ; > bcf GLOBAL_INTERRUPT When an interrupt occurs, GIE is cleared. You don't need to clear it. But when you do, clear it in the following loop: Lable bcf INTCON,GIE btfsc INTCON,GIE goto lable 0therwise, executing an interrupt and RETFIE could re-inable the interrupt you've just tried to clear. >--- >interrupt routine . . . . >--- > bsf GLOBAL_INTERRUPT Don't do that. RETFIE will enable GIE on exit. Enabling it early can cause recursive interrupts, and crash your stack. > movf save_s,w > movwf status > movf save_w,w > retfie swapf STATUS_BACKUP,W ;Restore working reg's now that ISR's done movwf STATUS ; swapf W_BACKUP swapf W_BACKUP,W retfie ;End of ISR Disable RBIE and INTE if not in use, otherwise input on RB0, RB4-7 can result in interrupts. Good luck.