Behavior of pins during reset state

Hello, I have a question. What is a behavior of the pins when the Arduino is being reset? Are they all going high or low or they stay in previous state? Or are they just floating?
Cheers

The detail of that probably depends on the particular 'Arduino' you are using.

The information would normally be found in the datasheet for the microcontroller your particular Arduino is using.

since the purpose of a pin is unknown at power up, I/O pins are set to INPUT at reset

@gcjr i was sure about that till yesterday.
Ddrxn registers initial bit values are 0 as per datasheet. I.e. input.

Portxn initial values are 0.
So as per datasheet they are input in hi-z condition.

pinMode(pin,INPUT) must do exactly that.

But here is paradox i observed yesterday with arduino pro micro.

To make rtc miso pin operate with other device attached to it there was line right at the beginning of the code
pinMode(13,INPUT).
Which i just deleted taking into assumption datasheet of 328p.
Device which was getting clock from rtc through pin13 didnt work or showed corrupted data on display like 4f:70 instead of actual time.
As per their schematic and resistance test right on pcb line is going from rtc miso pin connecting with pin13 pad and continuing to one of the pins on the other end.
Think of connected directly.
But it turned out its not that easy. I connected directly without arduino in place didnt work. Tried 4 different rtc modules didnt work.
Went back to code. Commented line about pinmode- didnt work.
Deleted whole code left just pinmode(13.input) in setup-did work.
Switched to writing directly to registers nothing made any sense till i got it working by:
Explicitly writing 0 to DDRB
DDRB=0;
Then
Explicitly writing 0 to bit pb5
PORTB&=~(1<<pb5);

Thats it with only this 2 lines in place
behaved as pinMode(13,INPUT).
Deleting first line or second line causes same issue.

Which means after restart pins are not input at least for pin 13 on arduino pro micro

not following your explanation

what is the problem?

so pinMode (pin, INPUT) is redundant unless you recofigure the pin from OUTPUT.

a pull-up or pull-down may be necessary if a pin needs to be in a specific state at power up and before configured as an OUTPUT

No what im trying to say is:
If after reset/restart pins are configured as input and 328p datasheet confirms that then pinmode(pin,input) is not needed if before that no manipulations were done on the pin right?

But yesterdays issue confirms the opposite i.e. after restart pin state is unknown at least on pin13 on arduino pro micro.

Is bootloader doing something with that pin? Can someone confirm that?

after restart pin state is unknown at least on pin13

what do you mean by unknown?

if it were an output and either HIGH or LOW, it could drive an LED (low resistance). If it's in INPUT in a high impedance state it could not drive an LED connected to from Vcc to the pin or visa versa

“ since the purpose of a pin is unknown at power up, I/O pins are set to INPUT at reset”

This is to what im referring to. 13pin is NOT set to input at reset.

And the proof of that i presented in my previous posts.

surepic:
“ since the purpose of a pin is unknown at power up, I/O pins are set to INPUT at reset”

This is to what im referring to. 13pin is NOT set to input at reset.

And the proof of that i presented in my previous posts.

All pins are set to INPUT at reset time for the ATmega chips.

The bootloader then goes on to set the mode of the serial pins (0, 1) and the built-in LED pin (13 on Uno etc).

Then the sketch runs (or a new one is downloaded and run).

Here we go!
That explains the whole nightmare i had yesterday with that pin.

Thanks a lot MarkT i suspected that bootloader is doing something there but couldnt get what exactly it does.

So for an update for arduino at least is that on reset some pins state is unknown unless you explicitly initialize them.

U cant assume as i was doing that pin states will match with datasheet. They are not.

I think now that its forming voltage divider for input of the device that rtc is connected to and making it to work. Cos as i said if connected directly rtc-device data showing on display is corrupted. Only if im connecting via pin13 in Input mode the other device is starting to get non corrupted data.

Awesome MarkT - thanks!