Recently i decided to make a project with the Atmega328P-PU. I 'm using this board to run the microprocessor.
This board has an 7805 regulator from ST electronics among with 10uF caps.
Also there is an external oscillator at 16Mhz with 2x22pF caps and a 10KΩ resistor from 5V to RST pin.
I have also added a 100nF capacitor from between the pins of AVCC and GND (pins 20, 22).
The peripherals of this board is an LCD Display 2x16 as output and a lm35 temperature sensor to the analog pin A0
I made the programming of the chip using the Arduino Uno board.
The problem that I am facing is that most of the time, when I plug it for the first time, it 's working just fine. If I try to unplug and plug it again the chip actually isn't working at all (doesn't start).
I have noticed (not very sure about this) that if I leave it for some period of time unplugged and try to plug it again most of the time is starts working with no problems, and again after this I face the same problems.
The problem that I am facing is that most of the time, when I plug it for the first time, it 's working just fine. If I try to unplug and plug it again the chip actually isn't working at all (doesn't start).
Without a scope, it is hard to know what to suggest. However, I suspect that perhaps the crystal oscillator is stopping... or maybe the RESET line is not pulled high (could not see a 10K pullup resistor.)
The 10K resistor is just behind the 2x22pF caps. Is there a possibility for the oscillator to work sometimes and sometimes not? I'm thinking of replacing it.
The 10K resistor is just behind the 2x22pF caps. Is there a possibility for the oscillator to work sometimes and sometimes not? I'm thinking of replacing it.
Crystals "can be" problematic, however, the issue is usually a cold solder joint or board contamination that is "loading" he oscillator signal. Some forum members recommend setting the crystal fuse to "full swing" but I also recommend a very good cleaning with isopropyl alcohol and then using a hair dryer on low heat / high air volume to dry the board completely. Often, flux will contaminate the board and while flux is not conductive, moisture and other contaminants such as finger oils can cause havoc.
Is AVCC connected to VCC? Needs to be.
Should have 0.1uF caps on both VCC and AVCC to GND.
Might also try a small signal diode like 1N4148 across the 10K reset pullup resistor, anode on Reset and cathode to +5. Dissipates any spikes on the Reset pin that might be putting the 328P into high voltage programming mode and looking hung to you.