The code *looks* OK to me so I'll suggest a few other things which can't be tested directly by looking at this code segment but which may be the problem. i You say this code is only meant to progress if PORTA = 00000100 Actually the test you are doing is is xxxxx1xx as the AND eliminates the other bits. This means that if RA2 is high the code will proceed. ie IF the ignition is ON (1) you will proceed even if the doors are open or unlocked. Perhaps the comment relate to an earlier program version which has now changed. IF you wanted it to proceed only if ALL of these 3 were HIGH then you would need to do something like WAIT2 MOVF PORTA, W ; get port A into W ANDLW b'00000111' ; check RA0(doors closed), RA1(doors locked) and RA2(ignition off) EORLW b'11111111' ; complement all bits BTFSS STATUS,Z ; skip when result is zero GOTO WAIT2 Presumably Doors closed RA0 = 1 Doors locked RA1 = 1 Igntion on RA2 = 1 If the above ISN'T correct then you need to rethink (I think ;-)) ii Have you correctly defined STATUS for your processor (an unlikely error) iii Have you correctly defined Z for your processor (another unlikely error) -----Original Message----- From: Andreas Nyholm To: PICLIST@MITVMA.MIT.EDU Date: Monday, May 03, 1999 9:56 PM Subject: Help! >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 >