I was at a PIC seminar 2 ¸ years ago, and they suggested that you leave unused pins as outputs. At the seminar last month the suggestion was (different spokesperson) to let unused pins be inputs, and tie them low (or high). So... Anyway, an unused open input floating also causes the problem of an unexpected current consumption in sleep mode. Sven -----Ursprungligt meddelande----- FrŒn: Quentin Till: PICLIST@MITVMA.MIT.EDU Datum: den 11 april 1999 08:07 €mne: Re: Newbie Toggle Switch Woes >David Olson wrote: > >> start movlw b'11111111' ;set porta for input >> tris porta >> movlw b'11110111' ;set bit 3 for output >> tris portb >> clrf swst ;clear switch register > >Welcome to the wonder world of PIC's! >I notice you Tris all the unused pins as inputs, did you connect them to >ground? >If not, Tris all your unused pins as outputs, and do not tie them to >ground. > >There is an ongoing discussion about whether to make unused pins as >inputs and tie them to ground, or tris the pins as outputs and just let >them float. Find out what works best for you. > >Also, your input pin for the switch, did you use a pull up resistor to >keep the input pin high when the switch is not made? > >The rest of your code is fine. You can make the code a whole lot >shorter, but as you are still learning, I am not going to tell you, >figure it out yourself. Tip: PortA and PortB are also registers. > >Quentin >