Combining Ports?

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.

Reply to
EdV
Loading thread data ...

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.

Reply to
Anthony Marchini

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.

Anth> > Address(0..7) to PortD

make a

case

of

Reply to
EdV

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.

Reply to
Anthony Marchini

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.