Since your code seems simple I guess you may have a hardware problem! If I understand your circuit properly you are using one pin to ground the C through R, then the other pin to sense the voltage. And the third pin hopefully floats so it doesn't affect anything. Since it is not detecting low, my guess is the voltage on the capsense pin is not going below the bottom threshold. This could be caused by three things; * there is a current leak holding the cap voltage high * there is not enough current drain to pull the volts down * voltage mismatch with pin types Put a voltmeter on the cap. See if it below the bottom threshold. Disconnect the float pin to see if that is leaking to hold the cap volts up. Check the volts on the low output pin, it may be too high. My *guess* is you have quite a high value resistor from the cap to the low pin, the PIC low voltage can be as high as 0.6v. The low input threshold is about 0.8v for the TTL inputs and 0.2v for the schmitt inputs. If you capsense is schmitt input that might explain it?? What value is your discharge resistor?? -Roman David VanHorn wrote: > > I'm having trouble with an I/O function. > > I have a capacitor, connected through three resistors, to three I/O pins. > The Capsense pin connects to the cap through a 1k resistor. > The other two pins are varying resistance. > If I set them as inputs, then the resistances don't matter. > If I set either one as output, then it charges or discharges the cap at a > rate determined by it's resistor. > > The basic idea is to read the cap RC time constant, as a form of A/D converter. > > Everything's fine, till I get to the point where I want to watch the cap > discharge, until it's low, before taking one of the other pins to output high. > > Read_Function: > btfsc PORTB,Capsense ;loop here till low on cap sense pin > goto Read_Function ; > > The Capsense pin is set as an input, as is one of the other two pins > The third is an output, and I can see that it is low, and that the voltage > on the capsense pin is also low, but the code loops here forever, > indicating that it's seeing a high input. > > I've walked through all the banking, and I believe that I'm in the right > banks when I'm talking to PORTB and TRISB. > > I've disabled all peripherals that would otherwise use portb pins. > > So, how could I get stuck here, given a low on the Capsense pin of portb? > > -- > Where's dave? http://www.findu.com/cgi-bin/find.cgi?kc6ete-9 > > -- > 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