Understanding the ATmega328P Microcontroller Connections

I created these notes to help better understand the ATmega328P microcontroller and significance of its pins, at the time of soldering. They also contribute towards an understanding of the schematic. Please feel free to suggest changes.

The Microcontroller (ATmega328P)

The ATmega328P is one of the most popular AVR-based microcontrollers. What is a microcontroller? As explained at Wikipedia, a microcontroller is ā€œa small computer on a single metal-oxide-semiconductor (MOS) integrated circuit chipā€. It has, at the very least, a CPU, memory and input/output interfaces. They are commonly used as the ā€˜brainā€™ of a simple device (as in our case).

What does AVR mean? Strangely itā€™s not officially an acronym but just a name for a popular family of microcontrollers. You can read more here.

The ATmega328P is a high performance, low power, 8-bit microcontroller with a host of features, including:

  • operating voltage of +1.8 V TO +5.5V
  • 23 programmable in/out lines
  • an SPI interface
  • 6 analog channels connected to a 10-bit ADC
  • 32K program memory
  • 2K RAM
  • 1K EEPROM
  • a watchdog timer
  • 6 power modes

Thereā€™s a lot of information available on this chip online. Just Google it.

The Power Pins

The ATmega328P is basically a complex circuit with a few points exposed to us as pins. As you will find with any logic circuit, we need positive and negative/ground power to make the circuit work. You will see from the schematic (and any datasheet you Google for the ATmega328P) that the positive power (VCC) should be provided at pin 7 and ground at pins 8 and 22.

There is also another positive power pin (20) for the analog-to-digital converter inside the the ATmega328P. We will come back to this later.

You can see these connections made to VCC and GND from the schematic, by looking at the board and probing it with a multimeter.

The SPI Interface

This is a nice topic to start with as it relates to the previous topic Understanding the SD Card Slot.

The ATmega328P can be a SPI host and thatā€™s exactly whatā€™s happening here. The SD Card is the slave and the microcontroller the host. Therefore the four SPI pins CS, MOSI, MISO and SCLK pins (16, 17, 18 and 19) we discussed before are connected directly to their corresponding pins on the SD Card Slot.

If you were paying attention youā€™d notice that there is an SPI bus on the board (many SPI slaves connected to the same MOSI, MISO or SCLK pins) so the host can communicate with many different SPI slaves - in this case the ICSP port, the LCD screen and the SD card. We will look at the ICSP port and the LCD screen in due course (these notes are made as I solder so they are in the order of soldering).

Reset Pin

On the ATmega328P datasheet you will see the reset pin is active-low, from the line above the word RESET, meaning that it should be kept at a high voltage until you want to reset the microcontroller. To reset, it must be brought to a low voltage for at least 2.5 microseconds. So a pull-up resistor should connect this pin to VCC and a reset switch or button should connect the pin to ground when triggered. We can see this being implemented at the bottom-right of the schematic - we will discuss it again at when we come to the ā€˜second 10k resistorā€™ and one of the ā€˜100nF capacitorā€™.

More to Come

There are many more connections to/from the microcontroller to other components. But I havenā€™t soldered those components yet so Iā€™m not sure of their role. I will add more to these notes as I continue the project.

2 Likes

Great job Mike!

Thatā€™s some very detailed work right there.

Thank you for sharing this with everyone, keep it going!

Cheers,
Robert