Where to set pinMode?

I have a complex sketch running on a Mega 2560.

The setup() function has mainly Serial.begins, Serial.prints and a few pinModes and digitalWrites to set pins HIGH for the OUTPUT pins.

If I put the pinModes and digitalWrites at he end of setup(). they don't work. On a DMM, they float at about 0.15-V.

If I move them to immediately after the Serial.begins, they work with solid 0.00-V and 5.10-V for LOW and HIGH respectively.

I can't see anything in the setup() script that might affect pin states.

My question is, is there an optimum place in setup() to configure pins or is my assumption that they can go anywhere in setup() wrong?

I haven't come across this problem before.

Thanks

You can put pinMode anywhere it makes sense, so post the code. Using code tags.

Please also feel free to provide some details, like which pins.

Clearly you've got an issue with your code.

tigger:
If I put the pinModes and digitalWrites at he end of setup(). they don't work. On a DMM, they float at about 0.15-V.

Sounds like your code is never reaching the pinMode() lines. Do you have any loops, function calls or return statements in your setup()?