Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

var=PINx dynamic

 
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: Wed Mar 03, 2021 12:10 am    Post subject: var=PINx dynamic Reply with quote

To read a port one writes a statement like

MYByte = PINA
or
MYByte = PinC.3

Is it possible to have the C and the 3 be variables?

like MYByte = Readpin Port_Number . bitnumber
Where Port_Number and bitnumber are Varibles?

(BASCOM-AVR version : 2.0.8.3 )
Back to top
View user's profile
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 971

poland.gif
PostPosted: Wed Mar 03, 2021 1:48 am    Post subject: Reply with quote

For what chip because any may be addressed differently....Mega Xmega? Offset?
Back to top
View user's profile Visit poster's website
O-Family

Bascom Expert



Joined: 23 May 2010
Posts: 320
Location: Japan

japan.gif
PostPosted: Wed Mar 03, 2021 4:00 am    Post subject: Reply with quote

Code:
   Mybyte Alias Pina
   Mybit Alias 3

   Config Mybyte.mybit = Input
   Set Mybyte.mybit


   Dim Bitnumber As Byte

   Bitnumber = 1
'   Config Mybyte.bitnumber = Input                          'This will result in an error.
   Set Mybyte.bitnumber

   Bitnumber = 2
   Set Mybyte.bitnumber
 
Back to top
View user's profile Visit poster's website
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 971

poland.gif
PostPosted: Wed Mar 03, 2021 4:05 am    Post subject: Reply with quote

I dont investigate it but it is obvious that you cant set PINx.... you can only set PORTx or DDRx
Back to top
View user's profile Visit poster's website
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 971

poland.gif
PostPosted: Wed Mar 03, 2021 5:12 am    Post subject: Reply with quote

I make mistake here Very Happy
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Wed Mar 03, 2021 10:05 am    Post subject: Reply with quote

only the BIT part can be used with a variable.
The port part is not variable but you could make a function for that.
In the Xmega it would be simple, while in the normal AVR all the ports have different address.

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

Bascom Member



Joined: 30 Dec 2019
Posts: 165

blank.gif
PostPosted: Wed Mar 03, 2021 11:24 am    Post subject: Reply with quote

Hi,
I can't imagine what you need it for. Perhaps I can only think of creating a library. It works for output values and I used it but not in Bascom. I assume Bascom assigns translation registers based on the processor's def file. If you would like to do so you can assign the registry address of your variable to the beginning of the program and then work with it. But there is an unpleasant complication in losing the direct address option and turning it into an indirect one. So the advantage of In,Out,SBI,CBI will be lost to you.
RS
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