Date sent: Mon, 3 May 1999 13:04:56 +0300 Send reply to: pic microcontroller discussion list From: Andreas Nyholm Subject: Help! To: PICLIST@MITVMA.MIT.EDU > Hi!! > Can anyone tell me what's wrong with this part of my program?? > > ; Wait for doors closed AND doors locked. > WAIT2 MOVF PORTA, W ; get port A into W > ANDLW b'00000100' ; check RA0(doors closed), RA1(doors > locked) and RA2(ignition off) > BTFSC STATUS,Z ; skip when result is zero > GOTO WAIT2 > > As you see am I taking porta into W, and it is supposed to go forward in > my program only if porta is 00000100 but that isn't the truth... > It's always continuing with the program and never goes back to WAIT2. > I have also tried with SUBLW but that didn't work either... With the > SUBLW function did I also try with BTFSS instead of BTFSC and then did > it loop in WAIT2 for ever.. > I'm glad if anyone can help me with this. > Andreas Hello Andreas, If You want to compare the value in a port (or any other register) with a known value and only act if they are equal You should use XOR instead of AND. XOR sets the ZERO flag if all bits are exactly the same. Use AND if You want to check individual bits one at a time. ============================== Ruben Jvnsson AB Liros Elektronik Box 9124, 200 39 Malmv, Sweden TEL INT +4640142078 FAX INT +4640947388 ruben@2.sbbs.se ==============================