At 07:29 01/17/99 -0800, Dave Johnson wrote: >OK, so a couple things need to happen here. The PIC needs to wake if >either the serial port opens (I use RB0/INT for this) or if the button is >pressed (RB4) while it's asleep. And while the PIC is awake, it needs to >notice and record any button presses. > >As you can imagine, I'm using most of the i/o lines on the PIC, and there >aren't enough on porta that I can use portb ONLY for the interrupt on >change feature. In particular, the A/D control lines are RB1-3 > >Right now, portb change interrupts are on all the time, so any button >press causes an interrupt. This seemed to be the simplest way to go. But >it appears now this may not be a good idea: particularly in "automatic" >mode, when portb is being twiddled frequently (to work the A/D and ), >I'll probably miss the occasional button press. > >The best solution I can see right now is to only enable the portb change >interrupt right before the PIC sleeps. Am I right in assuming that since >there will be no other portb accesses ('c uz it's sleeping), I will >ALWAYS get the change interrupt and wake up again? I sure hope so. > >The rest of the time, while the PIC is awake, I'll poll the button state >manually in my main loop to detect a button press. > >Does anyone see any difficulties with this approach? Any and all advice >gratefully accepted. if you can live with maybe loosing some serial data while button is pushed (i'm assuming you use RB0 as RxD), you could wire the button ORed (additionally) to RB0, where it would generate an interrupt, and you could read it at its port. (if it isn't pushed, it is a serial interrupt). or if you have one spare input, OR both the RxD and the button to RB0 and use it only as interrupt line (for both), and do the actual reading of the serial port on the other pin. in this case no lost data. ge