Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Programatically read ports

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
syndetic1

Bascom Member



Joined: 02 Jan 2007
Posts: 76

blank.gif
PostPosted: Fri Dec 03, 2021 5:30 am    Post subject: Programatically read ports Reply with quote

Dim A as Byte
A = PORTB

gets port B into variable A

Is there a way that "B" can be a variable

eg something like A=PORT(VAR)

(BASCOM-AVR version : 2.0.8.4 )
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Sat Dec 04, 2021 11:27 am    Post subject: Reply with quote

look at INP() and VARPTR()
PORTB like any other register is located at an address in memory. and you could do somethings like :
someWord=varptr("PORTB")
someByte=inp(someword)

the address can be constructed at run time like any other var, but there is no run time info which means code like :
someString="PORT"
input "some letter" , letter
somestring=somestring + someletter
this would create a string like portb, portX etc.
but varptr() can not resolve thtat !

_________________
Mark
Back to top
View user's profile Visit poster's website
syndetic1

Bascom Member



Joined: 02 Jan 2007
Posts: 76

blank.gif
PostPosted: Sat Dec 04, 2021 11:08 pm    Post subject: Thank you Reply with quote

Thank you
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR 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