Since we want to deliberate completely from Arduino we should buy a new ATMEGA328P-PU or an ATMEGA168-20pu chip.
These chips come already bootloaded for arduino or not. If you are not sure what bootload is then buy a bootloaded chip.
The price of a bootloaded chip is bigger from one that is'nt. Learn more about how bootloading your chips for free here!
Place your bootloaded chip into your arduino board. Reload the code to the new chip and test it.
Now your new chip have the same code and it is working ! Remove it from the arduino board and place the original chip back to it's place.
The minimal circuit in order to get a functional ATMEGA328P-PU up and running is offered in the picture.
The schematic has been made with KiCad we will talk a lot about kicad in other posts. Now let's focus on the circuit.
First of all we need to download the documentation (datasheets) . Below you can find some useful links
- ATMEGA328P-PU Summary
- ATMEGA328P-PU Full documentation
- ATMEGA168-20pu Summary
- ATMEGA168-20pu Full documentation
- Arduino cheat sheet
From the summary ATMEGA168 documentation at page one we can clearly see that we have the following operating voltages.
–1.8V - 5.5V for Atmel ATmega48V/88V/168V
–2.7V - 5.5V for Atmel ATmega48/88/168
So we decide to give a 5V input voltage. This can be done using a 5V Voltage regulator.
A known 5V Voltage regulator is the LM7805 a detailed documentation can be found here (LM7805)
From the figure 1 at page 7 of the pdf we can see a default configuration for this component. As you can see there are two capacitors C1 and C2 one on the input of the device and one of the output. These capacitors ale called filtering caps. Filtering capacitors are large capacitors that help smooth out ripple (noise coming in the input pin).
The led D1 and ιt's 330 Ω resistor can be removed but it is a good idea to have them as output indicator.
Again from the arduino cheat sheet we can easily see that the ATmega328 and the ATMEGA168 the pin 7 (VCC) and pin 20 (AVCC) should be connected to 5V and the pins 8 and 22 (GND) should be connected to GND.
The RESET pin on the ATmega needs to be connected to VCC. You can either wire the RESET pin directly to 5V or by connecting the RESET pin to VCC through a 10K resistor. If the reset button "grounds" then the ATmega will reset, so in order to function the chip we need that the pin1 should be HIGH.
It is really good to decouple the VCC(7) and GND(8) pins with a 0.1uF capacitor C3. You can remove this component too but helps with the ripple as we have said before.
Any microcontroller needs a clock source. The ATmega168 ships configured with an internal 1MHz (not accurate) oscillator.
Since we use a 5V input e can setup at the ATmega168 a better - 16MHz and more accurate external crystal using the pins 9,10. Notice that a lower voltage could not handle a 16 Mhz oscillator.
The 22pF capacitors C4,C5 help load the crystal allowing it to oscillate. Without C4,C5, the crystal may not start oscillating and this will mean that the microcontroller won't start.