I have a program that uses a bunch of switches and LED's on the SPI interface using MOSI/MISO and GPIO's for latching. The problem I have is when turning on the AVR the LED's go crazy few seconds. Sometime all (24) light up. This can potentially burn out the 74HC595 shift register IC's used for the LED's. Also when say 20 or more of the LED's are lit up the 250mA wall wart power supply can't regulate and the AVR can get hung up.
I'm new to AVR's and microcontrollers in general and I'm wondering how I should initliaze things to get control of the LED's immediately. Do I just try to initialize the SPI and the Port used for the latches first in main()? Is there some other way I can control the boot up sequence of the AVR?