user83251: So Let say I want to access Digital Pin 13. Thats port B pin. Is there an memory address associated with this pin 13 of Arduino Uno r3?
How Port B pins are addressed with corresponding pin numbers like What is the address of digital pin 13?
Currently I am assuming its pin address is 0x05 so my pointer looks like this
    uint8_t *adr=0x00+0x05;

Now If I do
  *adr |= 0x20;

then should I expect that I am writing to some pin so I like to know which data sheet I should refer for pin addresses of port B?
Currently my code is not working because no matter which pin I connect my LED to it blinks. What if I dont want to use any library and just write to address and I need PORT B pin address how to refer to different pins?
Now assume I have a code that uses avr gcc
#include <avr/iom328p.h>//avr/io.h
#include    <util/delay.h>
#include <avr/sfr_defs.h>


#define     BLINK_DELAY_MS  18000

int main (void)
{
    DDRB |= _BV(DDB5);

    while(1)
    {
        PORTB |= _BV(PORTB5);
        _delay_ms(BLINK_DELAY_MS);

        PORTB &= ~_BV(PORTB5);
        _delay_ms(BLINK_DELAY_MS);
    }

    return 0;
}

What is the values correspond to DDRB and _BV(DDB5); and PORTB and _BV(PORTB5);? I like to do it with pointers so I need addresses of PORT B all pins I know the macros but I like the actual addresses . there should be a some datasheet for this what  its called. Does arduino has it that gives memory mapped addresses?
The above code is simply for blinking LED light

user7508: The address of PORTB can be found in the ATmega328P datasheet,
section “I/O-Ports”, subsection “Register Description”. It is repeated
near the end of the section “Register Summary”, where it is documented
as:
0x05 (0x25)

Admittedly, this is confusing: there are two addresses! There is a
footnote that gives some hint on the reason:

When using the I/O specific commands IN and OUT, the I/O addresses
0x00 - 0x3F must be used. When addressing I/O Registers as data space
using LD and ST instructions, 0x20 must be added to these addresses.

To clarify, this register is mapped in two different address spaces:

It has I/O address 0x05. The I/O address space is a small (6 bits)
address space dedicated to I/O registers. It is actually too small to
host all the I/O registers. It can be accessed with the in and out
instructions. Addresses lower than 32 can also be bit-addressed with
the instructions sbi, cbi, sbis and sbic.

It has data address 0x25. This is a much larger address space that
gives access to all the I/O registers and to the RAM. It is used with
the ld/st family of instructions.


Since the C and C++ languages are not aware of the I/O address space, a
regular data pointer is assumed to always point to the data address
space. Thus, if you want to create a pointer to this register, you may
write:
volatile uint8_t *adr = 0x25;  // PORTB

Note the volatile qualifier. This is required to prevent the compiler
being too “smart” and optimizing out some of your writes under the
assumption that this is just RAM.
Then you may turn the LED on with:
*adr |= 1 << 5;  // set PORTB5

Withe the proper optimization options, the compiler may be able to
optimize this into sbi 0x05, 0x05, if it can prove that the address
stored in the pointer doesn't change.

I need addresses of PORT B all pins I know the macros but I like the
actual addresses.

I would recommend this:
volatile uint8_t *adr = &PORTB;

This avoids having magic numbers in your code, and makes the
programmer's intent clear.
One last comment. When compiling your code I got:
include/avr/iom328p.h: [...]
error "Include <avr/io.h> instead of this file."

Just include <avr/io.h>: this header takes care of including both the
correct <avr/iomXXX.h> and <avr/sfr_defs.h>.

83251: <p>So Let say I want to access Digital Pin 13. Thats port B pin. Is there an memory address associated with this pin 13 of Arduino Uno r3?</p>
<p>How Port B pins are addressed with corresponding pin numbers like What is the address of digital pin 13?</p>
<p>Currently I am assuming its pin address is <code>0x05</code> so my pointer looks like this</p>
<pre><code>    uint8_t *adr=0x00+0x05;
</code></pre>
<p>Now If I do</p>
<pre><code>  *adr |= 0x20;
</code></pre>
<p>then should I expect that I am writing to some pin so I like to know which data sheet I should refer for pin addresses of port B?</p>
<p>Currently my code is not working because no matter which pin I connect my LED to it blinks. What if I dont want to use any library and just write to address and I need PORT B pin address how to refer to different pins?</p>
<p>Now assume I have a code that uses avr gcc</p>
<pre><code>#include &lt;avr/iom328p.h&gt;//avr/io.h
#include    &lt;util/delay.h&gt;
#include &lt;avr/sfr_defs.h&gt;


#define     BLINK_DELAY_MS  18000

int main (void)
{
    DDRB |= _BV(DDB5);

    while(1)
    {
        PORTB |= _BV(PORTB5);
        _delay_ms(BLINK_DELAY_MS);

        PORTB &amp;= ~_BV(PORTB5);
        _delay_ms(BLINK_DELAY_MS);
    }

    return 0;
}
</code></pre>
<p>What is the values correspond to <code>DDRB</code> and <code>_BV(DDB5);</code> and <code>PORTB</code> and <code>_BV(PORTB5);</code>? I like to do it with pointers so I need addresses of PORT B all pins I know the macros but I like the actual addresses . there should be a some datasheet for this what  its called. Does arduino has it that gives memory mapped addresses?</p>
<p>The above code is simply for blinking LED light</p>
 7508: <p>The address of <code>PORTB</code> can be found in the <a href="https://ww1.microchip.com/downloads/en/DeviceDoc/ATmega48A-PA-88A-PA-168A-PA-328-P-DS-DS40002061B.pdf" rel="noreferrer">ATmega328P datasheet</a>,
section “I/O-Ports”, subsection “Register Description”. It is repeated
near the end of the section “Register Summary”, where it is documented
as:</p>
<pre><code>0x05 (0x25)
</code></pre>
<p>Admittedly, this is confusing: there are two addresses! There is a
footnote that gives some hint on the reason:</p>
<blockquote>
<p>When using the I/O specific commands IN and OUT, the I/O addresses
0x00 - 0x3F must be used. When addressing I/O Registers as data space
using LD and ST instructions, 0x20 must be added to these addresses.</p>
</blockquote>
<p>To clarify, this register is mapped in two different address spaces:</p>
<ul>
<li><p>It has I/O address <code>0x05</code>. The I/O address space is a small (6 bits)
address space dedicated to I/O registers. It is actually too small to
host all the I/O registers. It can be accessed with the <code>in</code> and <code>out</code>
instructions. Addresses lower than 32 can also be bit-addressed with
the instructions <code>sbi</code>, <code>cbi</code>, <code>sbis</code> and <code>sbic</code>.</p>
</li>
<li><p>It has data address <code>0x25</code>. This is a much larger address space that
gives access to all the I/O registers and to the RAM. It is used with
the <code>ld</code>/<code>st</code> family of instructions.</p>
</li>
</ul>
<p>Since the C and C++ languages are not aware of the I/O address space, a
regular data pointer is assumed to always point to the data address
space. Thus, if you want to create a pointer to this register, you may
write:</p>
<pre class="lang-cpp prettyprint-override"><code>volatile uint8_t *adr = 0x25;  // PORTB
</code></pre>
<p>Note the <code>volatile</code> qualifier. This is required to prevent the compiler
being too “smart” and optimizing out some of your writes under the
assumption that this is just RAM.</p>
<p>Then you may turn the LED on with:</p>
<pre class="lang-cpp prettyprint-override"><code>*adr |= 1 &lt;&lt; 5;  // set PORTB5
</code></pre>
<p>Withe the proper optimization options, the compiler may be able to
optimize this into <code>sbi 0x05, 0x05</code>, if it can prove that the address
stored in the pointer doesn't change.</p>
<blockquote>
<p>I need addresses of PORT B all pins I know the macros but I like the
actual addresses.</p>
</blockquote>
<p>I would recommend this:</p>
<pre class="lang-cpp prettyprint-override"><code>volatile uint8_t *adr = &amp;PORTB;
</code></pre>
<p>This avoids having <a href="https://en.wikipedia.org/wiki/Magic_number_(programming)" rel="noreferrer">magic numbers</a> in your code, and makes the
programmer's intent clear.</p>
<p>One last comment. When compiling your code I got:</p>
<pre><code>include/avr/iom328p.h: [...]
error &quot;Include &lt;avr/io.h&gt; instead of this file.&quot;
</code></pre>
<p>Just include <code>&lt;avr/io.h&gt;</code>: this header takes care of including both the
correct <code>&lt;avr/iomXXX.h&gt;</code> and <code>&lt;avr/sfr_defs.h&gt;</code>.</p>
