Hi Stewart It's ok with you example. But I didn't understand why I can't read the Port B and make a operation like xor with it. regards Stewart Pye a ˇcrit : > Hi Michel > > Your problem is portb is configured as an output. You then try to move > portb to w and xor it with b'01000010'. That's why you get both leds on. > There is a much simpler way to do this any way. From your first call alum: > (this asumes the leds are active high) > > repeat > btfsc porta,0 ;is ra = 0..... > goto rb6on ; > rb1on > clrf portb ;yes > bsf portb,1 ;turn on rb1 > goto repeat > rb6on > clrf portb ;no > bsf portb,6 ;turn on rb6 > goto repeat > end > > This should work, though you would normally debounce the switch by waiting > 5ms after the test to check that it is still in the same position. > > Regards, > > Stewart Pye > At 07:52 7/05/99 +0200, Michel Mermin wrote: > >Hi > > > >I'm a beginners with the pic 16F84 and I've got a problem. With a switch > >connected to RA0, I'm trying to switch on a led connected to RB1 and > >switch off another one connected to RB6 for a switch position ans switch > >Off RB1 and siwtch on rb6 for the other position. > > > >The case where RB1 is on and RB6 if off is ok, but the other case the 2 > >leds are on with a voltage of 2v5 instead on 5v. > > > > > > title "MM1" > >; > >; fait clignoter PB1 > >; > > LIST P=16F84 > > errorlevel 0,-305 > > INCLUDE "P16F84.inc" > > > >; Registers > > __CONFIG _CP_OFF & _WDT_OFF & _XT_OSC & _PWRTE_ON > > > >; Mainline of PROG16 > > > >temp equ 1 > > > > org 0 > >Debut > > clrf PORTB > > bsf STATUS,RP0 > > movlw b'00000000' > > movwf TRISB > > movlw 0xFF > > movwf TRISA > > bcf STATUS,RP0 > > call Alum > ;******** > > > >Repeat movf PORTA,w > > andlw b'00000001' > > btfss STATUS,Z > > goto ZNUL > > call Etein > > goto Repeat > >ZNUL call Alum > > goto Repeat > > > >Alum movlw b'00000010' > > movwf PORTB > > return > > > >Etein movf PORTB,w > > xorlw b'01000010' > > movwf PORTB > > return > > end > >