Arduino mega 2560 using PORTS

Hello,
Currently i am engaged, with the project where, i need total 5 arduino digital output ports. Every digital port contain 8 bit.
what exactly, i am doing is, converting decimal to binary and writing it on IO port.

Following IO ports i have successfully configured and working fine for me.

  1. PA0 - PA7 (This port contains pin no 22,23,24,25,26,27,28,29)

  2. PC0 - PC7 (This port contains pin no 30,31,32,33,34,35,36,37)

  3. PL0 - PL7 (This port contains pin no 42,43,44,45,46,47,48,49)

  4. PB0 - PB7 (This port contains pin no 50,51,52,53,4,5,6,7)

Problem comes from here, when i need 5’th port.

For 5 th port i am using

PH - in which

PH0 - Pin 17
PH1 - Pin 16
PH2 - Not connected on any IO pin
PH3 - Pin 6
PH4 - Pin 7
PH5 - Pin 8
PH6 - Pin 9
PH7 - Not connected on any IO pin

PH2 and PH7 are not connected on any IO pin , so i am thinking to use the combination of two ports, In which 6 bits can be used by PH port and for rest two bits i can use some other port like PE

PE - in which

PE0 - Pin 0 (it is recommended to not to use this pin)
PE1 - Pin 1 (it is recommended to not to use this pin)
PE2 - Not connected on any IO pin
PE3 - Pin 5
PE4 - Pin 2
PE5 - Pin 3
PE6 - Not connected on any IO pin
PE7 - Not connected on any IO pin

So basically i have pin 3,4,5 in PE port, in which 2 pins i can use for (PH2 and PH7).
i am stuck in creating a logic for this.
I do not have arduino code because i am using different platform (LabVIEW) for creating the program.

Please let me know if any other information is required.

Thanks and regards

So what you really want is the convenience of changing all 8 bits at once simply by a single byte written to the port register, correct?

Yes, absolutely right.

You still have 2 whole ports available: PF0-PF7 = A0-A7 PK0-PK7 = A8-A15

if i am not wrong, in this case we need some logical operation like AND of two bytes.

Data for PH port ---------------------------> write on PH port register

Data for PH port AND X data ----------------------> write on PE port register

This is what i was trying but not able to find the X data

oqibidipo: You still have 2 whole ports available: PF0-PF7 = A0-A7 PK0-PK7 = A8-A15

Ya. Good call.

I thought this ports only for analog data. Can i use these ports for Digital output??

They have PORT, DDR and PIN registers. Why would those exist for analog-only pins? In other words, they are digital pins that can also be used as analog inputs.

Sure. Good idea as well if you're not going to use those pins for analog is to turn off the ADC. It gets turned on by default during the Arduino build process by all those things that happen in the background. Consumes a bunch of power unnecessarily if not needed.

oqibidipo: In other words, they are digital pins that can also be used as analog inputs.

Are they not 'physical pins' which could be connected to: (a) external digital devices and the signals could be routed to the internal Digital Module/Port, (b) external analog devices and the signals could be routed to the internal ADC Module/Port?

"You still have 2 whole ports available: PF0-PF7 = A0-A7 PK0-PK7 = A8-A15"

Worked!!

Many thanks to all of you.