Jump to content
mityeltu

Port Encapsulation... Union? Struct?

Recommended Posts

mityeltu    0

I am trying to encapsulate 2 ports from 18F2620 into a single variable. What I want to be able to do is something like the following pseudocode

 

variable ex_port = porta:portb // 16 bits of 2 ports in a single variable

for (z = 0, z<16, z++)

ex_port.z = 1

next z

 

what I'm trying to do is to sequence through both ports as well as to be able to address each individual port pin wihtout having to first address the individual port. I hope that makes sense.

 

Is there some way to bundle the ports together like this?

 

Since boostc does not support bitfields, this becomes pretty large if I used a structure of bytes.

I hope I'm not just making this way harder than it needs to be. Is there an easy way?

Share this post


Link to post
Share on other sites
JorgeF    0

Hi

 

The problem is not to join the 2 ports under a single 16 bit variable as long as the 2 ports have concecutive addresses in RAM, , like exemplified by richardc.

 

The real problem is beeing able to scan all the bits in a loop.

The dot (.) operator when applied to bit access has a serious limitation, it doesn't acept a variable for the bit number.

So you can access all 16 bits (x.0 to x.15) but you can't use the loop index to do it, only compile time constants.

 

Best regards

Jorge

Edited by JorgeF

Share this post


Link to post
Share on other sites

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoticons maximum are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×