On Tue, 26 Mar 2002 15:27:05 -0500, Steve Kasm wrote: >Hello All, > > > >I have portb,5 connected to a relay through a 2.2k resistor to the base >of a 2n2222a transistor, the trans has collector to relay coil and >emitter to ground. > > > >My problem is that when I set portb,5 to a high in my software, I get a >pulse out of the output pin that snaps the relay and then drops it. The >only way I can get the relay to stay up is to put the bsf, portb,5 >instruction in a loop which basically sends a pulse train to the >transistor that holds the relay up. > I'd recommend doing all of your BSF (and BCF) PORTx instructions on a 'shadow register' in RAM and writing the RAM value to the port.=20 The BSF and BCF instructions first read the port, then modify what was read, and finally write the result back to the port. This can cause no end of problems that are very hardware dependent. > > >I need this relay to operate when the bit is set outside of a loop, >could I be drawing to much current from the pic pin? Would this cause >the output not to latch up when set? > Any other BSF or BCF instruction to the same port can clear (or set) the state of any other bit on the port. The ANDWF, IORWF, XORWF, ADDWF and SUBWF can as well.=20 If you do a piclist archive search for read-modify-write, you should be able to find a wealth of additional information on this effect. Regards, Bob -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body