Combining Ports?
CASTalk.com Forum Index CASTalk.com
Discussion of DSP, FPGA, storage and embedded system.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web castalk.com
Combining Ports?

 
Post new topic   Reply to topic    CASTalk.com Forum Index -> Embedded System
Author Message
EdV
Guest





Posted: Tue Dec 21, 2004 2:20 am    Post subject: Combining Ports? Reply with quote

I am using the P18F8720's many io pins to write usart data to a 32K
NVRAM. I don't have room for an address data latch so I am assigning:

Address(0..7) to PortD
Address(8..15)to PortJ
Data(0..8) to PortE
WE/ to PortB.0
OE/ to PortB.1

At least that is what I thought I wanted to do before I started to
write the code. Is there some way to combine PortD and PortJ to make a
16 bit register? Or some way to move values from the upper byte of
Address to PortJ and the lower byte to PortD?

I could use a chain of conditionals to move Address bytes to Ports but
it seems clunkier than necessary.

Thanks much,
Ed V.
Back to top
Anthony Marchini
Guest





Posted: Tue Dec 21, 2004 5:48 am    Post subject: Re: Combining Ports? Reply with quote

Quote:
Address(0..7) to PortD
Address(8..15)to PortJ
Data(0..8) to PortE
WE/ to PortB.0
OE/ to PortB.1

At least that is what I thought I wanted to do before I started to
write the code. Is there some way to combine PortD and PortJ to make a
16 bit register? Or some way to move values from the upper byte of
Address to PortJ and the lower byte to PortD?



This chip appears to do all data operations as byte anyways, so it
should be a simple matter to transfer the high and low bytes to the
respective ports.
The question makes me think that you are perhaps using C, in which case
there should be a way to get a pointer to the "two byte int" or
something like that, then you just get one and then the next byte out of
it like this :

int reg16;
byte * x;
x = & reg16;
PortJ = *x++;
PortD = *x;

I am just guessing about the C part, since the question appears to be
moot by virtue of the chip operation.
T.
Back to top
EdV
Guest





Posted: Tue Dec 21, 2004 10:18 pm    Post subject: Re: Combining Ports? Reply with quote

Thanks.

I found a C language refrence and ended up using right shift and it
worked just fine.

I will look into your pointer suggestion as I need to use that part of
my brain more often.

Ed V.


Anthony Marchini wrote:
Quote:
Address(0..7) to PortD
Address(8..15)to PortJ
Data(0..8) to PortE
WE/ to PortB.0
OE/ to PortB.1

At least that is what I thought I wanted to do before I started to
write the code. Is there some way to combine PortD and PortJ to
make a
16 bit register? Or some way to move values from the upper byte of
Address to PortJ and the lower byte to PortD?



This chip appears to do all data operations as byte anyways, so it
should be a simple matter to transfer the high and low bytes to the
respective ports.
The question makes me think that you are perhaps using C, in which
case
there should be a way to get a pointer to the "two byte int" or
something like that, then you just get one and then the next byte out
of
it like this :

int reg16;
byte * x;
x = & reg16;
PortJ = *x++;
PortD = *x;

I am just guessing about the C part, since the question appears to be
moot by virtue of the chip operation.
T.
Back to top
Anthony Marchini
Guest





Posted: Wed Dec 22, 2004 3:05 am    Post subject: Re: Combining Ports? Reply with quote

EdV wrote:
Quote:
Thanks.

I found a C language refrence and ended up using right shift and it
worked just fine.

I will look into your pointer suggestion as I need to use that part of
my brain more often.

Ed V.

The nice thing about pointing to the register is that it doesn't destroy

the original as shifting will do. You won't have to make a copy before
shifting it 8 bits and loading it out.
T.
Back to top
 
Post new topic   Reply to topic    CASTalk.com Forum Index -> Embedded System All times are GMT
Page 1 of 1

 
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




VoIP Electronics Powered by phpBB