BasicMicroUK - Forums

www.basicmicro.co.uk
It is currently Tue Apr 24, 2018 7:12 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: A Pin Mapping Trick to read the State of a Pin
PostPosted: Mon Jun 15, 2015 2:25 pm 
Offline
Guru

Joined: Fri Dec 07, 2012 3:48 pm
Posts: 67
According to the manual (Basic Micro Studio Reference Manual_V2_1): "Pin names are constants and can not be used to read the state of a pin directly..."

You have to check the Specific INx or OUTx Port, so this code does NOT work:
Code:
Set_Switch    CON   P0

IF Set_Switch = %1 THEN
    ; Do some stuff
ENDIF




:D However, if you assign a Pin Variable directly to an INx (or OUTx) Port like this, you can check the State directly:
Code:
Set_Switch    VAR   IN0     ; Use “INx” instead of “Px”

IF Set_Switch = %1 THEN
    ; Do some stuff
ENDIF



I have also made a new table of the Pin and Port Variables (combination of the tables in the manual), which I have attached as a DOCX file.


Attachments:
Pin and Port Variable Names.docx [15.4 KiB]
Downloaded 106 times
Top
 Profile  
 
 Post subject: Re: A Pin Mapping Trick to read the State of a Pin
PostPosted: Wed Jun 17, 2015 3:46 am 
Offline
Site Admin
User avatar

Joined: Fri Apr 12, 2013 8:38 pm
Posts: 87
Location: Nottingham, England, UK
HI Andre

Thanks for your input to the forum once again and very useful information to make for more readable programs,

I can see the forum settings that are not allowing DOCX files to be downloaded and I have now changed that to allow that file format, BAS is already allowed so should work OK so please give it a try and let me know if there are still problems,

Many thanks

Dave
BasicMicroUK


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


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 post attachments in this forum

Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO