Could you please tell me what the pin output is between Step 1 and Step 2?
Will the pin output be in an undefined or unexpected state between Step 1 and Step 2?
tbacarrot:
Could you please tell me what the pin output is between Step 1 and Step 2?
Will the pin output be in an undefined or unexpected state between Step 1 and Step 2?
Step 1 only needs to be performed once, typically in setup(), to setup the hardware to drive the pin High or Low as needed late in loop() using digitalWrite.
Those pages describe the chip reset state, which need not be the same as what the early arduino codes sets them to. I don't think that the arduino code DOES document this at all, although it does leave them in the chip reset state, and of course you can look at the code.
Normally the first digitalwrite is so soon after the pinmode that it doesn't matter.
westfw:
Normally the first digitalwrite is so soon after the pinmode that it doesn't matter.
If you use Port Manipulation you can reduce the gap to a single clock cycle (62.5ns).
IIRC digitalWrite(pin, HIGH) when in INPUT mode changes the mode to INPUT_PULLUP and I don't know what happens when the pin is then changed to OUTPUT mode (too lazy to read the datasheet).
westfw:
Those pages describe the chip reset state, which need not be the same as what the early arduino codes sets them to. I don't think that the arduino code DOES document this at all, although it does leave them in the chip reset state, and of course you can look at the code.
Normally the first digitalwrite is so soon after the pinmode that it doesn't matter.
I completely see your point, however it is hard to imagine a good reason why the initialization code would deliberately set them to a high state at startup.
They seem to have a hard time documenting everything that they do, let alone what they don't do.