On Tue, Mar 26, 2002 at 04:39:35PM -0000, Gary wrote: > Hi, > > I am having a problem with waking my 16F628 from SLEEP, I want it to wake up when the button is pressed, in other words RB0 is now at 0V. I have set the PIC to wake up on the falling edge, does this mean that when the button is at 0V = PIC now awake?, as this is how I understand it? > No. It mans that the pin must go from a high state to a low state in order to trigger. Your circuit below will generate such a falling edge. > Problem= If long cables are used for the switch, it picks up noise and the software thinks the button has been pressed! > Two possible solutions there. First is to use a stronger pullup resistor. Second is to add another resistor and a capacitor into the circuit to that the line cannot instanteaneously change. That way noise will be filtered. Something like this: +5 | R1 | +---R2---+-----RB0 | | S C | | +----+---+ | GND Make sure that R2 is much smaller than R1 so that when the switch is pressed that the voltage divider will output a low voltage. For example if R1=10k and R2=100 then the output voltage will be 50mV which should be low enough to trigger the interrupt. > The problem is that I cannot find away of debouncing the button, as the way I have it configured, it will not Wake Up until the button is pressed AND released, the exact opposite of what I want. > Well that's sounds like a rising edge. BTW the above circuit will help with debounce also. > I want it to wake on Button down AND wait X milli seconds, then check it is still at 0V, the code I have written, is below, and the button connections, any ideas where I am going wrong? > No clue. But I bet that cleaning up the noise will help significantly. BAJ -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body