Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

RLF Coding Problem

Status
Not open for further replies.

Suraj143

Active Member
Hi I have a small code problem in my 4 digit SSD circuit.

When I power up it shows 0000 & check every time the RB7 has press.
If it presses then the CURSOR (G segment) is moving to DIGIT1.
When I press RB7 again the CURSOR moves to DIGIT2 using RLF & continues.

My problem is when the CURSOR register comes to 5th bit (btfss Cursor,5) it wont go to the count routine it goes to the Keychk routine so I cannot continue to start counting.

Somebody please help me to solve this problem

Code:
Scan	----			;contains multiplexing stuff
	----
	return

Count	----			;increment digits
	----


Keychk	----			;checks the four buttons
	----
	goto main


Main	call	Scan
	moclw	b'01111110'	;make portb,7 low
	movwf	PORTB
	call	SmallDel	;small delay to settle
	btfsc	PORTB,7		;check the RB7 press or not?
	goto	Keychk		;no then goto keycheck
	bcf	STATUS,C       ;yes then clear the carry bit
	rlf	CURSOR,f	;move cursor to left by one
	btfss	CURSOR,5	;has the 5th bit cursor set?
	goto	Loop1		;no then goto loop1
	clrf	Cursor		;yes 5th bit is set then -
	goto	Count		;- goto count routine


Loop1	call	Scan
	btfss	PORTB,7		;check the RB7 has released?
	goto	Loop1
	goto	Keychk
 
You don't need to make RB7 to be low if you set it as input.
What's the initial value of CURSOR?
If you have 4 SSD, you should check bit 4 right?
 
bananasiong said:
You don't need to make RB7 to be low if you set it as input.
Hi banansiong RB7 is connected to one LED. When I need an input I make that pin RB7 low. (Also before returning from scan I make RB7 as an input pin from making bsf TRISB, 7)

What's the initial value of CURSOR?
If you have 4 SSD, you should check bit 4 right?

Before comes to the main routine the cursor value is 1 (one)
 
Suraj143 said:
Hi banansiong RB7 is connected to one LED. When I need an input I make that pin RB7 low. (Also before returning from scan I make RB7 as an input pin from making bsf TRISB, 7)
But I see in your main program:
Code:
Main	call	Scan
	moclw	b'01111110'	;make portb,7 low [b](so RB7 is input now)[/b]
	movwf	PORTB
	call	SmallDel	;small delay to settle
	btfsc	PORTB,7		;check the RB7 press or not?
	goto	Keychk		;no then goto keycheck
	bcf	STATUS,C       ;yes then clear the carry bit
You said RB7 is set to be input before returning from Scan, so can you still control this bit as output?
 
bananasiong said:
You said RB7 is set to be input before returning from Scan, so can you still control this bit as output?

Hi bananasiong something I missed to tell you.

RB7 buttons ground path is connected to RB7 & the other side connected to RB1.

Button is in the middle RB1 & RB7 same like in keypads.

So if I want to make this as an input what I do is RB1 as INPUT (before returning from scan) & makes RB7 as low
 
The problem is when the CURSORs 5th bit is set it wont goto the Count routine to count.So I cannot count.I have missed something.

Code:
Scan	----			;contains multiplexing stuff
	----
	return

Count	----			;increment digits
	----


Keychk	----			;checks the four buttons
	----
	goto main


Main	call	Scan
	moclw	b'01111110'	;make portb,7 low
	movwf	PORTB
	call	SmallDel	;small delay to settle
	btfsc	PORTB,7		;check the RB7 press or not?
	goto	Keychk		;no then goto keycheck
	bcf	STATUS,C       ;yes then clear the carry bit
	rlf	CURSOR,f	;move cursor to left by one
	[B][COLOR="Red"]btfss	CURSOR,5[/COLOR][/B]	;has the 5th bit cursor set?
	goto	Loop1		;no then goto loop1
	clrf	Cursor		;yes 5th bit is set then -
	goto	Count		;- goto count routine


Loop1	call	Scan
	btfss	PORTB,7		;check the RB7 has released?
	goto	Loop1
	goto	Keychk
 
Hi Mike I must clear the cursor because the segment show the G segment as the cursor.
If I set the cursor it to "1" then the 1st digit segment shows the cursor.In this period I can press the 4 key buttons & set a number.
When the cursor is = 4 then the digit four segment show the cursor & I can press the 4 key buttons & set a number.

Now when I press the RB0 & RB1 button cursor is = 5 so no more cursor showing in the display & I can countup.
 
I suggest you post the count routine as I suspect that is where the problem is.

Mike.
 
Ok Mike I'll post the full code.
I gave half code because it was quite long & hard for viewers.Ok I'll post the full code withing few hours.

Thanks
 
Hi guys I got it done.The problem was I have missed a loop & also the CURSOR must check the bit 4 not 5.

Thanks a lot.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top