;****************************************************************************** ;int_demo_18 ;This program demonstrates setting of high and low priority interrupts, ;and context saving. ;External Interrupt 1 is set as high priority, Port B change is set as low. ;Intended for simulation only. ;TJW 14.2.09 Tested by simulation 23.2.09 ;****************************************************************************** #include P18F2420.inc ; org 00 goto init ;high priority interrupt vector org 08 goto hi_pr ;low priority interrupt vector org 18 goto lo_pr ; ;Initialise interrupts init bcf intcon2,rbip ;set port B change to low priority movlw B'01001000' ;enable Int 1, hi priority movwf intcon3 bsf rcon,ipen ;enable interrupt priority movlw B'11001000' ;set Global enable high and low, and port B change movwf intcon ;Main loop loop movlw 55 ;store a test value in W reg nop nop goto loop ;High priority ISR hi_pr movlw 11 ;change value in W reg bcf intcon3,int1if retfie 1 ;Low priority ISR lo_pr movlw 33 ;change value in W reg movf portb,1 ;a dummy read must be made to Port B before the flag is cleared bcf intcon,rbif retfie end