If the external AND gate has one GPIO connected to each input, and assuming it's a 6 input AND gate, ALL pins would have to be HIGH for the output to go HIGH. If there are any unused inputs on the AND gate, ie an 8 input AND gate, pull each of them HIGH with a 10K or so ohm resistor. The reason it works for the case of writing -1 is that this makes the PORT take the value of '255', or all pins HIGH (0-1=255). Try using an OR gate in place of the AND gate, and see if that works. Regards, Jim > I've built a small cable-tester. In a loop, I have these lines: > > movlw b'00000001' ; run cable test on GP0 > movwf GPIO > call delay_500ms > > movlw b'00000010' ; run cable test on GP1 > movwf GPIO > call delay_500ms > > movlw b'00000100' ; run cable test on GP2 > movwf GPIO > call delay_500ms > > movlw b'00010000' ; run cable test on GP4 > movwf GPIO > call delay_500ms > > movlw b'00100000' ; run cable test on GP5 > movwf GPIO > call delay_500ms > > Each of the corresponding GPs are connected to an LED and an > (external) AND-gate. The problem is, none of the LEDs are being lit > when using the above code. > > Even more weird, if I insert this piece of test-code (light all LEDs): > > movlw -1 > movwf GPIO > call delay_500ms > clrf GPIO > call delay_500ms > > between the GP0/GP1 tests above, all LEDs are being lit. > Step-debugging in MPLAB and watching the GPIO, I clearly see > "00000001", "00000010" etc in GPIO for the various tests, but none of > them are being lit. > > I also tried this: > > movlw b'11111100' > movwf GPIO > call delay_500ms > > Then the LEDs are instantly flashing (for like 0.1 ms, just barely > noticeable) before turned off. > > I've been scratching my head for a couple of hours now, > double-checking the datasheets but I just can't see what's wrong. It > works for all the LEDs at the same time, but not one at a time. > > Can anyone explain what's happening? Could it be a RMW-problem? I > can't think of anything right now. > > > -- > - Rikard - http://bos.hack.org/cv/ > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist