O.K i'll refer to your first code.
Lets assume that PORTC is set to input... but i'll prefer to set it myself..
TRISC=255 'PORTC as all input
And now this snippet ..
Code:
loop:
if portc.0=0 then
b0=b0+1
select case b0
case 1
'
'
'
'
goto loop
Your select case will never work untill you press all the button down...
To fix it:
Code:
loop:
b0=PORTC 'get the reading of PORTC
select case b0
case 1
BUT if i refer to your schematic, we will need to revert the logic or use other CASE.
I mean. If you need to read only PORTC.0 =0 the result comming from your PORTC will be %11111110 or 254 and blah blah blah for all the other option. If you feel safer to read like this
PORTC.0=0 PORTC=1
PORTC.1=0 PORTC=2
PORTC.2=0 PORTC=4
and blah blah blah
what you have to do is to use a simple XOR $ff like this
b0 = PORTC ^ $ff
and now you have the *normal* bit reading from PORTC.
To implement your stuff it will look something like this
Code:
loop:
b0 = PORTC ^ $ff
select case b0
case 1
gosub menu1
case 2
gosub menu2
case 4
gosub menu3
case 8
gosub menu4
'
'
'
end select
goto loop
that's it that's all , basketball
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks