A quick peek at the datasheet (hint, hint) reveals that PORTA has a dual duty with analog comparators. I don't see any disabling code for those in your code...that's almost certainly the problem: the PORTA pins need to be configured as digital pins. The following code should disable the comparator: movlw b'00000111' ; the lower 3 bits of CMCON control the status of ; the compartor movwf CMCON CMCON is in bank 1, so no selection needs to be done. Alles klar? Mike H. >From: rrc124+@PITT.EDU >Reply-To: pic microcontroller discussion list >To: PICLIST@MITVMA.MIT.EDU >Subject: [PIC]:beginner needs help with input pins, read all the FAQ >Date: Tue, 10 Jun 2003 20:47:34 -0400 > >I can't get my inputs to work. I am using a pull up switch, have set all >pins but 1 to outputs, then tied them to ground. I am using a PIC16F628 >with the configs set to everything off/disabled except the power up timer. >I have selected the internal oscillator. I'm a programmer..not EE, so >that's my weak point but i have been checking the circuit for 3 days and >can't find what's wrong. The chip works because i got one of those LED >blinking things to work fine. Guys...thank you so much...it's very >upsetting when you're just starting out and can't get the easiest thing to >work. The only odd thing i could find was that my programming software >(WinPicProg, from Dontronics) generates a different config word then does >MPLAB with the same settings. > >Here is my code: > >TMR0 EQU 1 >OPTION_R EQU 1 >PORTA EQU 5 >PORTB EQU 6 >TRISA EQU 5 >TRISB EQU 6 >STATUS EQU 3 >ZEROBIT EQU 2 >CARRY EQU 0 >PCON EQU 0EH >COUNT EQU 20H > > LIST P=16F628 > ; tells which processor is use >;MPLAB generated __CONFIG 0x3F10 > __CONFIG 0x3D10 ;WinPicProg generated > > org 0 > goto START > >; config section > >START bsf STATUS, 5 > movlw b'11111111' > movwf TRISA > movlw b'00000000' > movwf TRISB > > movlw b'00000100' > movwf OPTION_R > clrf PCON > > bcf STATUS, 5 > clrf PORTA > clrf PORTB > >; program starts now > >BEGIN btfsc PORTA, 1 > goto BEGIN > movlw b'11111111' > movwf PORTB >KEEPON btfss PORTA, 1 > goto KEEPON > clrf PORTB > goto BEGIN > > END > >Here is my circuit: > GND > | >[9V+ Battery]--[914 diode]--[7805 Volt Reg]--+ > | > +-----[10k Res]----+ > | | > A1/PIN 18-----+--[switch]--GND | > | > Vdd/PIN 14------------------------+ > > Vss/PIN 05------------------------GND > > B4/PIN 10--[470 Ohm Res]--[LED]--GND > > B3/PIN 09--[470 Ohm Res]--[LED]--GND > >All other pins set as output, tied to ground. The switch part of the >circuit allows 4.5V to A1 and when pressed drops the voltage down to 0. I >checked with my multimeter. Thank you so much everyone. > >E-Mail: rrc124@pitt.edu > >Robert Campbell > > >-- >http://www.piclist.com hint: To leave the PICList >mailto:piclist-unsubscribe-request@mitvma.mit.edu _________________________________________________________________ Help STOP SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu