On 28 Jan 99, 11:09 Andrew Hall wrote: > I want to use a 16F84 to monitor two independant frequencies via a > couple of port pins (maximum frequency 60Hz). This requires the PIC to > spot transitions on the pins. I would like to avoid polling as the PIC > has other tasks to perform. > I know there is an interrupt on PORTB change feature but I seem to > remember a "piclister" saying there are problems with this technique. The interrupt on change on port b works quite well, as long as you do all your port B access (all bits, not just to those that might trigger an interrupt) in the interrupt handler. I fell into that trap just recently, when I monitored the pulses from a bicycle generator (~300 hz) in a "port b change interrupt" routine, but did all other stuff, including polling another pin, toggling yet another one for sound, etc. in the main program. I didn't get any interrupts at all, it almost drove me crazy. I finally realized the problem just by thinking it over (the documentation is quite unclear about it, it just just vaguely recommends against using polling and intterupt on change, without giving a reason). After moving almost everything into the interrupt handler, and after moving the "check port B status" out of the "first level" interrupt handler and calling it from both the interrupt handler AND every port B access (including output access!), everthing worked fine at the first attempt. > > Could anybody advise on this or any other technique which might be > appropriate ? In short: you have to take into account that you can and occasionally will miss port B interrupts each time your programm accesses the B port in any way. That's it. This has some implications, not all of them obvious. -- o ( Wolfgang.Strobl@gmd.de (+49 2241) 14-2394 /\ * GMD mbH #include _`\ `_<=== Schloss Birlinghoven, __(_)/_(_)___.-._ 53754 Sankt Augustin, Germany ________________