Tim H. wrote: > PER_INT BTFSS INTCON, RBIF ; PortB interrupt? > > GOTO OTHER_INT ; Other interrupt > > BTFSC PORTB, RB7 ;Check for rising edge > GOTO CLR_RBINTF ;Falling edge, clear PortB int >> ; flag >> ;Do task for INT on RB7 >> > CLR_RBINTF MOVF PORTB, 1 ; Read PortB (to itself) to end mismatch > condition > > BCF INTCON, RBIF ; Clear the RB interrupt flag. > > RETFIE ; Return from interrupt > OTHER_INT : ; Do what you need to here >> > RETFIE ; Return from interrupt > > According to the app note, the ISR will run the needed code on the > rising edge of a wide pulse and ignore the falling edge. I've gone > over this hundreds of times and can't figure why they used BTFSC. > Looking at the code tells me that the ISR will run when RB7 is low, > which would be a falling edge, right? This is bad code all around. Microchip app notes are full of bad code. You are right, the comments describe the opposite polarity from what the code does. There is also another problem in that any new changes to port B between testing the bit and clearing the condition will be missed. Here is a slightly modified snippet from some of my working code: ; ; Process port B change interrupt. ; dbankif gbankadr movf lastb, w ;make temp copy of previous input bits movwf ireg2 dbankif portb movf portb, w ;end the mismatch condition bcf intcon, rbif ;clear the interrupt condition movf portb, w ;get base value for next change detect dbankif gbankar movwf lastb ;update last IR input bits state xorwf ireg2 ;make flags for changed bits in IREG2 ; ; The new state of the port B bits is in LASTB, and the mask of ; changed bits in IREG2. ; ***************************************************************** Embed Inc, embedded system specialists in Littleton Massachusetts (978) 742-9014, http://www.embedinc.com -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics