Posted: Thu May 25, 2006 3:45 am Post subject: Comparing port bit
Hi
I'm trying to compare the polarity of a port pin and the bascic does'nt allow me to do it. I want th check if the port pin status as change
Dim Gear_previous As Bit
Gear_in Alias P0.4
gear_previous = gear_in
set gear_in
do
...
call gear_check()
loop
Sub Gear_check
If Gear_in <> Gear_previous
Then
Waitms 25
If Gear_in <> Gear_previous Then
Gear_previous = Gear_in
Call Position_
End If
End If
End Sub
Bascom give me an error on this line : If Gear_in <> Gear_previous
Joined: 25 May 2004 Posts: 190 Location: Ljubljana, Slovenia
Posted: Tue Sep 19, 2006 9:18 am Post subject: My answer might be not correct, but
My answer might be not correct, but
When compare is made and one of arguments in portpin you need to take in consideration this:
I think, that bascom does not read port in if statement. I think, that bascom supposes that the value of Px.y is that, last used when portpin was writen.
The best way to verify my opinion is to try. I am not able to do this now, because of my hardware is down.
Try this way:
Write to port:
P1 = 255
then push some bit of port1 down with a switch connected between pin and ground then
if P1 = 255 then
print "Vilko is right "
else
print "Vilko is wrong"
endif
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum