Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Comparing port bit

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-8051 Archive
View previous topic :: View next topic  
Author Message
mtheriault2000

Bascom Member



Joined: 12 Oct 2005
Posts: 9

blank.gif
PostPosted: Thu May 25, 2006 3:45 am    Post subject: Comparing port bit Reply with quote

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

Whats wrong?

Martin
Back to top
View user's profile
Vilko

Bascom Member



Joined: 25 May 2004
Posts: 190
Location: Ljubljana, Slovenia

slovenia.gif
PostPosted: Tue Sep 19, 2006 9:18 am    Post subject: My answer might be not correct, but Reply with quote

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
Back to top
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-8051 Archive All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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