BTFSS PORTA,0
RETRUN ;BAD NUMBER
CALL DELAY10ms
BTFSS PORTA,3
RETURN ;BAD NUMBER
CALL DELAY10ms
BTFSS PORTA,1
RETRUN ;BAD NUMBER
CALL DELAY10ms
BTFSS PORTA,2
RETURN ;BAD NUMBER
GOTO SomeWhere ;GOTO anywhere since the code is correct
oh ok 1 minute i got the fix:
Is PORTA only for buttons? How are the buttons coming in?
like if you press number 2 is porta = 0000 0010 ?
Oh i think i see you are starting from :
0= 0x01 - 00000001
1 = 0x02 - 00000010
and so on am i right?
I think you misunderstood me. Im "trying" to check the inputs on PORTA against the code in the code1 register.
Hence BTFSS PORTA,code1.
Which of course doesnt work, which is my problem.
My code is dyamic, it can be changed...
Just doing BTFSS PORTA,0
or whatever, will work but im trying to compare against another register. The code isnt the same all the time.
Hi,
I'm new to PICs and have just begun programming a little alarm. I am using the PIC16F88.
The problem lies with :
BTFSS PORTA,code1
If I do a linear comparison like,
BTFSS PORTA,0
Everything works fine. But using code1 as the second parameter causes the code to fail (recognized as incorrect). I don't know how to do this part properly. I have tried calling up something to convert the "relative" bit positions from the "code" registers and convert them to pure binary then use that as a second parameter but that doesnt work either.
I don't know how to go about this.
Adam
I already compare 1 bit then the next etc.
I have 4 registers. code1,code2,code3,code4.
The snippet of code I posted is supposed to compare the first digit of the code only.
I do want to compare the input on portA to the code1. Then in the next code block I compare to code2 register. Etc. I simply posted the code1 section only as the rest are just slightly changed dupes.
E.g.
code1 = 00000001
code2 = 00001000
code3 = 00000010
code4 = 00000100
They are the registers. So that would be buttons 0,3,1,2 on porta. The contents change though, as I have a code setting routine to write to eeprom ealier on.
This works because 0 is one BIT of PortA. Code1 is a register you have defined, and that register has 8 bitsBTFSS PORTA,0
MOVLW PORTA
ANDLW 0x0F
INCF W
ANDLW CODE1
you might have to shift each bit and check if zero if you do it that way.. i think.. not sure ... if it was a 18F pic it would be way simpler.
Lol Nigel your in Derby like me. What a coincidence .
And I've also got two Cybots, and a website about them!.
That try was wrong -easy way to do it:
Read the entire port to W.
Transfer W to a GPR.
Check each of the bits in the GPR using either BTFSS or BTFSC, depending which way you're testing.
Also, use the include file names, I've no idea what 'Status, 2' means?, the correct way would be 'Status, Z' (assuming 2 is Z?).
My bad, used ANDLW code1 which obviously wont work.
Working code:
Code:Code1 MOVF PORTA, W BTFSC STATUS, 2 MOVF PORTA, W ANDWF code1, 0 MOVWF temp CALL Flag CALL Release RETURN
It works!!!!!!!! Flag checks every bit in temp.
My problems are solved. Thanks to everyone.
and
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?