Unused pins in MCU

How shall I configured unused pins with internal pull up registers in my software ?

Is there any examples to configure DDRX (Data Direction Register) and setting Port Register setting of unused pins in mapping mode instead of doing it one by one.

If using mapping mode how does the Port Register setting interfere in my program ?

Which kind of MCU? If it is ATmega, port registers can set up to 8 pins on the Arduino, depending on exact type of ATmega and its port number. If proper bit masking is used then other already used pins will stay untouched.

hamisu-anguan:
setting of unused pins in mapping mode instead of doing it one by one.

The default setting for all pins is INPUT.

If you are not using a pin why would you need to change that?

There are not so many pins that doing anything one-by-one is a huge chore.

...R

I am using ATMega328P-CU.

May I know how to do bit masking to keep used pins untouch.
So default unused pins is input, I do not actually need to perform bit masking am i right ?
I can just tied unused pins to GND or I need to tied with a resistor to GND ?
If there internal resistors in the IC which I can just tied to ground.

You can tie unused pins directly to GND or to +5v.

I have never found it necessary to do anything with unused pins.

...R

Robin2:
The default setting for all pins is INPUT.

If you are not using a pin why would you need to change that?

Floating pins increase power consumption due to undesired switching?

// Edit
Only now see your follow-up reply :frowning:

sterretje:
Floating pins increase power consumption due to undesired switching?

// Edit
Only now see your follow-up reply :frowning:

I don't have any projects where power consumption is an issue so I guess I had not considered that. Setting the pins to INPUT_PULLUP should stabilize matters.

...R