Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 09:45 17 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : How read cfg status of a pin?

Author Message
sagt3k

Guru

Joined: 01/02/2015
Location: Italy
Posts: 313
Posted: 08:11pm 14 Jun 2015
Copy link to clipboard 
Print this post

Hi to everybody
I need a instruction or a method that return me a config status of pins.
For a example, if I have set a pin with this instruction:
Setpin 7,AIN
Setpin 2,DIN
Setpin 3,DOUT
I need to read the cfg status with an instruction as GetPin(x)
This instruction could return me the current status of pin....:
>GetPin(7)
>AIN

thanks
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9079
Posted: 10:06pm 14 Jun 2015
Copy link to clipboard 
Print this post

As far as I know, this is not possible within the MMBASIC commands, but you could use simple flags to keep track of this:


SetPin 7,AIN:07FLAG$="AIN"
SetPin 2,DIN:02FLAS$="DIN"
SetPin 3,DOUT:03FLAG$="DOUT"


Naturally, that only works if you never change the pins around.
If you DID change the pins around, you would have to define the flag string every time you did that, which would then reflect the pin's function at any given time, by querying that pin flag.

To query pin3's current mode, you would just need to look in 03FLAG$ or Print 03FLAGS$, for example. This is very simplistic - there are probably better ways...

Are you likely to be changing the pin modes that often?
Smoke makes things work. When the smoke gets out, it stops!
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8603
Posted: 10:35pm 14 Jun 2015
Copy link to clipboard 
Print this post

  Quote   need to read the cfg status with an instruction as GetPin(x)


This should be possible with a very simple CFunction but isn't at the moment. I need it as well to use inside other CFunctions so I have asked Geoff to include the required "hook" in a future beta. I'll post a "GetPin" Cfunction when this has been included.Edited by matherp 2015-06-16
 
sagt3k

Guru

Joined: 01/02/2015
Location: Italy
Posts: 313
Posted: 10:54pm 14 Jun 2015
Copy link to clipboard 
Print this post

Hi Matherp
Thanks, the solution proposed by Grogster it's very interesting. CFunction it's another solution. But I need a intrinsic solution. My board with micromite firmware work with others hw. I use my board only to issue commands using only the micromite's prompt. I don't start with RUN or AUTORUN my micromite.
Thanks
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8603
Posted: 11:21pm 14 Jun 2015
Copy link to clipboard 
Print this post

  Quote   I don't start with RUN or AUTORUN my micromite.


You can use AUTORUN and have a program that ends almost immediately and returns to the command prompt. By doing this the prompt will then have access to any functions defined in the program. This allows you to massively extend the repertoire of the command prompt.
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9079
Posted: 11:43pm 14 Jun 2015
Copy link to clipboard 
Print this post

Brilliant idea, matherp, and so simple!!!!!
Smoke makes things work. When the smoke gets out, it stops!
 
sagt3k

Guru

Joined: 01/02/2015
Location: Italy
Posts: 313
Posted: 11:57pm 14 Jun 2015
Copy link to clipboard 
Print this post

Yes ...I know this method.
However I will use this method. So I will can set and manage a few of variables.
Ok
 
Chris Roper
Senior Member

Joined: 19/05/2015
Location: South Africa
Posts: 280
Posted: 01:53am 15 Jun 2015
Copy link to clipboard 
Print this post

You could possibly do it by interrogation of the TRIS and LAT registers via PEEk, but I have not used the PEEK and POKE functions so am not sure how or if they would address internal registers.


http://caroper.blogspot.com/
 
sagt3k

Guru

Joined: 01/02/2015
Location: Italy
Posts: 313
Posted: 02:19am 15 Jun 2015
Copy link to clipboard 
Print this post

Hi Chris
I think that the solution exposed by Matherp ...it's Excellent. Now I need align all my software with this solution.
Thank
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024