Sorry Bob but ( only ) this time your corection is not good because: rbif = 1; one of rb7,4 pins change state and must be cleared in software rbif = 0; none of rb7,4 have change state So, after an interrupt occure rbif must be cleared for the next one. Vasile On Fri, 16 Mar 2001, Bob Ammerman wrote: > See correction below: > > ----- Original Message ----- > From: Vasile Surducan > To: > Sent: Friday, March 16, 2001 8:01 AM > Subject: Re: [PIC]:PORTB int on change > > > > This is working for me, it test only low to high transition on rb7 and rb6 > > But it depends how long takes the interrupt source. There is an > > application note with this subject but I don't remember the number... > > All set flags must be cleared in main program. > > > > btfss intcon_rbif -- test if interrupt on change occure > > goto out -- if not, test other interrupts > > btfsc pin_b7 -- if yes, test which pin > > goto first > > btfsc pin_b6 > > goto second > > goto out > > first: > > bcf intcon_rbie -- disable irq on change > > bsf first_flag > > goto out > > second: > > bcf intcon_rbie > > bsf second_flag > > out: > > Next instruction should probably be a 'bsf': > > > bcf intcon_rbif -- prepare for next interrupt on change > > bsf intcon_rbie -- enable rb port change interrupt > > > > > > > > > > On Fri, 16 Mar 2001, brah wrote: > > > > > Hi people, > > > About the PortB int on-change. I've done a few experiments with mixed > > > results. Ive searched the archives, found mention of my problem, but > > > not the entire solution. > > > > > > Simply put - I need two independant external interrupts on an F876 > > > (and/or an F877) Or more simply put - I need two RB0,s! > > > The problems are: > > > I need an interrupt generated only on lo to hi, not both, as I need to > > > get the total time period of the pulse. i.e. one full cycle, not just > > > one side. So, I need an interrupt when the pulse goes hi, ignore it > > > when it goes lo, then another interrupt when it goes hi again. > > > And I have to do this from two separate inputs, and get two separate > > > times (I then compare the times and act according to the result) > > > The time periods vary, from a couple of milliseconds to several hundred > > > milliseconds. > > > I don't seem to be able to read from the port and find which state > > > caused the interrupt - either a hi to lo or a lo to hi, so I could > > > ingnore an interrupt I didn't want - as this seems to wreck the > > > interrupt on change. > > > So, how do I find out what polarity change generated the interrupt - lo > > > to hi or hi to lo? If I knew that, I could then ignore the unwanted > > > interrupt, and wait for the correct one. > > > I saw where someone tried diodes from another input pin, then reading > > > the other pin for polarity, instead of reading the int pin. Hmmmm. The > > > other pin might have to be on another port. I seem to get poor results > > > with diodes - my PICs seem to read right through them. Of course I'm > > > probably doing it wrong!! Anyone done something like this? > > > Also, to complicate things, I would like to (in fact probably will have > > > to) use the other pins on PortB for other functions - mainly outputs, > > > which some writers in the archives seem nervous about because of the > > > possibility of missing interrupts, or wrecking the on-change function. > > > Any ideas on how to detect the polarity on a particular portb interrupt > > > on change pin? > > > Regards to all > > > Howard Simpson. > > > > > > -- > > > http://www.piclist.com#nomail Going offline? Don't AutoReply us! > > > email listserv@mitvma.mit.edu with SET PICList DIGEST in the body > > > > > > > > > > -- > > http://www.piclist.com#nomail Going offline? Don't AutoReply us! > > email listserv@mitvma.mit.edu with SET PICList DIGEST in the body > > > > > > -- > http://www.piclist.com#nomail Going offline? Don't AutoReply us! > email listserv@mitvma.mit.edu with SET PICList DIGEST in the body > > -- 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