.
..
..
..

Exploring the heart of Arduino: The Atmega328P

Sep 04, 2020

A deep dive part-1

Many electronic enthusiasts and hobbyists nowadays begin their journey by learning to make arduino projects as opposed to analog electronics as was done in the old times. They find a blog/youtube video and copy the code to get their project up and running. The approach has some big advantages like the projects are very easy to debug, wiring is relatively simple and something useful,practical and applicable can be built using this approach fairly early in your electronics journey. After doing a handful of such projects one realises that hardly has he/she learnt about electronics. All that the person has learnt is to use the premade functions in the arduino IDE and many times not even that as the syntax has just been copied! Such a level of understanding is fair enough for a hobbyist , technician or a mechanic. But if you really want to level up your skills or be called an engineer one has to deep dive into the world or microcontrollers and computer systems architecture! As such topics can be intimidating we shall provide a basic introduction of Atmega328P: the heart of Arduino UNO and Nano in this series of blog posts. arduino An Arduino UNO board with all marked pins and peripherals

pinout

The datasheet we would be referring to here can be found using the link below: link. The datasheet provided above can seem very bulky, which it is but we shall guide you through the pages so do not worry.

On the first page itself we can find a lot of information. It provides a summary of all the main features and is a good starting point for the datasheet.We shall break down the facts for you. Atmega328P belongs to a family of microcontrollers known as AVR. Such type of devices use an 8 bit RISC architecture. Let us break the last sentence down. 8 Bit (0’s and 1,s)(aka a byte) is the width of the “data bus” that is being used by the CPU. The data bus is a set of ordered nodes that can be used by various peripheral devices , CPU and memory to communicate with each other. Consider a data bus to be like a conference table on which all the members are seated. The members can share data among themselves using the commonly available table top. RISC architecture is one among various types of architectures available in the market. Other variants are MISC,CISC etc. 8085 used CISC architecture whereas Atmega328P uses RISC architecture. RISC stands for reduced instruction set architecture. The details can be found elsewhere but for our purposes let us just assume it to be a type of language that the CPU and the peripherals use. The chip has 32 * 8 bit registers used for temporary storage of data for processing.1Kbytes EEPROM and 2Kbytes internal SRAM can also be found on the chip. SRAM can be used as a typical RAM and EEPROM can be used to save constants that you wouldn’t like to change much for example it may be the manufacturing date of the device etc. The chip uses Harvard Architecture which means that the program memory and the RAM are not being shared on a single memory unit and hence it makes it much faster as compared to the other available type the VonNeumann Architecture in which a single memory device is being used as both a RAM and the program storage space. The program in the chip is being stored on the on chip flash memory. A programming lock for software security is also available to lock your code on the chip but we won’t be using it much as its main function is to lock the code on the chip so nobody may be able to copy your code from a commercial unit.

von

We can see that the chip has various peripherals including various counters, clocks, PWM channels , comparators etc which shall be covered in a follow up blog. Till then I would recommend you to just have a look at the headings in the datasheet so when the terms are referred to later you find them more familiar.

Satvik Sharma

Satvik is the Electronics Lead at Team ARES.He has a keen interest in the field of Embedded Systems and Hardware Description Languages. His prime focus is on computer system architecture.