cassemblyavrarduino-uno

ATmega328p Memory Addresses


I learning to program the ATmega328p microcontroller in C and Assembler:

  1. In C, I define DDRB = 0x24.
  2. In Assembler, I define DDRB = 0x04

Can someone explain this difference in addresses (does that because the definition of the general purpose registers r0..r31, 0x00 .. 0x1F) ??


Solution

  • This is because the I/O address space is also mapped in the memory address space. It allows C to access them without using special instructions like OUT and IN.

    You can use the 0x24 in assembly too - using the load and store instructions

    It is not related to the language you use.

    I strongly advise you to read the AVR documentation.

    enter image description here