ATmega328P Ports Mapping

This is in continuation of last blog.  I will validate the ATmega328P concepts with practical approach. 

How ATmega328P Peripherals are mapped in Memory

mem5

Which AVR core is used in ATmega328P ? 

ATmega328P  name implies that it is  from megaAVR family of AVR core series. This precise information is required to understand instructions supported in this device.

Why there is a need to learn Assembly when we have C++ based Library ?

I will not recommend any  hobbyist to do into in-depth assembly because that will nullify whole concept of Arduino. However there is no harm in spending some time to understand the importance of Assembly.  Here are some basic points

Is Learning assembly a tough job ?

Not at all, It’s not a rocket science.  For RISC based architecture, You need mechanism:

Examples for decoding AVR Assembly Code :

I wrote a simple C code to display basic GPIO ports and analyzed  the disassembly of the same. The method to fetch assembly from executable file was discussed in blog.

Reading GPIO using Indirect Addressing :

You will notice that the disassembly file has a mixture of 16 and 32-bit instructions.

16-bit Instruction decoding

41a: 8b a1 ldd r24, Y+35 ; 0x23

32-bit Instruction decoding

Lets analyze a 32-bit instruction/opcode in the same code listing

16 bit I/O specific instruction

      Can we analyze assembly of PORTB reading  ? 

Exercise to be completed :

One can understand this concept  better by repeating the exercise > Hope you can decode the following long jump instruction discussed in last blog

References : All documents are available here. I am referring to most of these :

To understand the data addressing better , We can look into section The Program and Data Addressing Modes of  AVR Instruction set reference manual

Here are few other interesting topics @Embedkari

How to Learn C  practically ? 

How to choose sensor, processing device and network for IoT ?

How I can practice AVR, ARM, Linux and other Embedded Questions for Interview ? 

This article is  discussed at ATMega328 Ports Mapping.

Thanks for reading till end. Please provide your feedback regarding this article. Also subscribe  Embedkari for other interesting topics. .

Thanks for reading till end. I am trying to improve usability of my  site. Did you find this discussion helpful ? If so,  Please subscribe to YouTube channel Embedkari as well for additional embedded related stuff.

Exit mobile version