Hasan A. Khan wrote: > Hi, > Here is another new comer to PICs. I am relatively > new to hardware but not to software. I used to be > very passionate about electronics but then I went into > software. I have been writing/managing C++ then Java > Enterprise software projects for the past ten or so > years. Now I am back to my true passion: electronics. > Anyway, here is my question. > > I have a project using p16f628 where output (open > drain) of a comparator is connected back to CCP1 pin. > Comparator triggers the capture condition. CCP1 pin > is also used as PWM output when CCP is in PWM mode. > The datasheet says, "If the RB3/CCP1 is configured as > an output, a write to the port can cause a capture > condition." How does this work? How can an output read > the pin at the same time? > > If the write to output actually works, it will save me > some design effort and components. > > Thanks for your help. > > > > -Hasan Pins configured as outputs will still be able to read. In fact, if you read a port pin set as output you do not read the output buffer; instead, you read the pin as an input (which under normal conditions should be the same value that is being outputted, but under heavy loading might be different. This is why Read-modify-write instructions on port pins is a bad idea if you are using heavy loads. IIRC TRIS does not change what you read or write to the pin. It just enables or disables the output buffer. -- Hector Martin (hector@marcansoft.com) Public Key: http://www.marcansoft.com/hector.asc -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist