Toggle only LED1 Coding problem

Status
Not open for further replies.

Suraj143

Active Member
RB7 is multiplexed. In the ISR for every 500ms the RB7 toggles (on/off).

What I need is to turn on /off (toggle) the LED1.In my coding both the LEDs toggle.I don’t need to toggle both I need only LED1.

Please help me to solve it.

Thanks

Code:
MTPX	bsf	PORTA,0		;turn on LED0
	movf	M1,W		;get the jump value
	call	Delay
	bsf	PORTA,1		;turn on LED1
	movf	H1,W		;get the jump value	
	call	Table	
	btfsc	PORTB,7
	iorlw	b'10000000'
	movwf	PORTB							
	call	Delay1	
	goto	MTPX



Delay	call	Table		
	btfsc	PORTB,7		;has the bit7 is set?	
	iorlw	b'10000000'	;yes,then keep the bit7 show
	movwf	PORTB		
Delay1	decfsz	Del,F
	goto	$-1
	clrf	PORTA		;clrf PORTA
	movlw	b'10000000'	;clrf PORTB without harming bit7
	andwf	PORTB,F
	return
 

Attachments

  • Share.JPG
    5.1 KB · Views: 147
Last edited:
Forgot to tell the Two LEDs from two SSD.Thats why i multiplex them.

The coding works nicely but its toggling the both LEDs thats the problem.
 
You can do this way.
Code:
MTPX	bsf	PORTA,0		;turn on LED0
	movf	M1,W		;get the jump value
	call	Table
	[B][COLOR="Red"]andlw	b'01111111'	;ignore the RB7
	movwf	PORTB
	call	Delay1[/COLOR][/B]
	bsf	PORTA,1		;turn on LED1
	movf	H1,W		;get the jump value			
	[B][COLOR="Red"]call	Delay	[/COLOR][/B]
	goto	MTPX
 
Suraj143 said:
What I need is to turn on /off (toggle) the LED1.In my coding both the LEDs toggle.I don’t need to toggle both I need only LED1.
why not simple turn LED0 off , replace first line with
bcf PORTA,0
 
five0 said:
why not simple turn LED0 off , replace first line with
bcf PORTA,0

Hi it is because the LED is a Segment in the seven segment display.If I turn it off the whole segment is turning off.Thats y.

The Gayans method worked & I added some more to that.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…