Hi All, Apparently if you have an interrupt on the tmr0 overflow active, in my case this interrupt is updating the data in a 4511 and driving 4 transistors for a 4 digit LED display, then outputs on the PortB will not latch when the interrupt is running. By disabling the interrupt and blanking my display in code I was able to get the portb,5 port to latch it's output for my purpose. I guess you learn something everyday. Thanks all for your help Regards, Steve Kasm -----Original Message----- From: pic microcontroller discussion list [mailto:PICLIST@MITVMA.MIT.EDU] On Behalf Of Bob Barr Sent: Tuesday, March 26, 2002 4:02 PM To: PICLIST@MITVMA.MIT.EDU Subject: Re: [EE]: Pic16f84 Output to relay pulses instead of latch? 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. 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. 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 -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body