You have a rather surprising problem.
Does the micro have a 0.1 uF By-Pass cap across the Vcc and Ground, and AVcc and Ground pins, as close to the micro as possible?
Did you try, as suggested above, running on the internal RC Osc to see if the problem improved, (indicating an external Xtal and / or cap problem)?
Did you ENABLE the Brown out detector fuse?
If you are not familiar with what it does, ask.
If you are familiar with it, then we won't spend time discussing it.
Depending upon your specific external Xtal, and the capacitance of your traces on your PCB, the 18 pf caps could be too high, (although note that Evert suggested making them even larger, above). (So you have three choices: Leave them alone, make them bigger, make them smaller...)
Powering up the peripherals before you power up the micro is NOT a good idea.
The data sheet specifically states the allowable voltage on the I/O pins in the Electrical Characteristics section of the data sheet.
Bottom line: Having +5 V on a data line from a peripheral, (e.g. the LCD), to the micro, before the micro is powered up, is out of spec.
It is usually best to power them up together.
Have you put a digital storage scope on the V+ rail while powering up the circuit?
Does the power supply have enough power capability to properly power the circuit?
Atmel AVRs have an internal Power On Reset circuit.
Specific criteria must be met, or the POR circuit won't enable the micro to start running.
The voltage must be mono-tonic, (smooth, rising, no dips or glitches).
The rate of rise is also important, not too slow, not too fast.
In the old days, with large transformers, it was common to have several 1000 uF's on the INPUT to a 7805.
These days you have to be careful NOT to put too large a cap on the INput, or the power supply can't turn on fast enough.
As stated above, already, look at the data sheet for the specific 7805 you have, by specific manufacturer, and make sure you have the input and output caps in spec.
Check, as mentioned above, the current being drawn by the LCD's backlight. Make sure it is in spec, or reduce it while debugging your circuit.
JC
↧