---
title: "Basic question about basic adress"
url: "https://maker.wiznet.io/forum/11087"
markdown_url: "https://maker.wiznet.io/forum/11087/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "mrupprath"
created: "2015-06-03T07:24:32+09:00"
last_activity: "2018-06-02T03:48:09+09:00"
language: "en"
views: 914
replies: 2
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# Basic question about basic adress

## Question

Asked by mrupprath on 2015-06-03 in Ethernet Chips.

Hello;
I am just start developing with the 5300 (WIZ830MJ) and STM32F4 µC.
I am a little bit confused about these two things:

1. Base Address:
   Taken from the W5300 dazasheet"
   "Physical Address of W5300 Reg = Base Address of T.M.S + Address offset of W5300 Reg

For convenience, we assume the Base Address(BA) of T.M.S is 0x08000, and BA of the
Physical Address of W5300 Register is 0x08000."

I have studied some code examples, first I thougt, base address/ address of Mode Register always is 0x08000, but the address in the code example varies.

So what do I have to use in case of an STM32F4 Controller as Start address/First Adress:0x00000 or 0x08000 ???

1. “Taken from Datasheet Manual of W5300”
   “6.1.1 16 Bit Data Bus Width In case of using a 16bit data bus width, ADDR[9:1] is used and ADDR0 is connected to ground”

Question:
I defined GPIO Port E as Address Port:
How to write a Address to that Port from internal variable value ?
Because : Address uses 9 Portlines, Internal Variable, holding the address is uint_16 type (uint_16 W5300Address) for example
Do I always have to shift the value of W5300Address like : Output_to_Port_E = W5300Address &lt;&lt;1 ??

Thanks in advance

Marc

## Replies

### Reply 1 by Coccoliso, 2015-06-03

I can only answer for the first request, the base varies depending on the addressing mode you are set.
In Direct address mode :

```
COMMON_REG_BASE = 0x8000 
SOCKET_REG_BASE = 0x8000 + 0x0200
```

In Indirect address mode :

```
COMMON_REG_BASE = 0x0000
SOCKET_REG_BASE = 0x0200
```

… but maybe this piece of code can serve for the second question

```
uint8 IINCHIP_READ(uint16 addr)
{
#if (__DEF_IINCHIP_ADDRESS_MODE__ == __DEF_IINCHIP_DIRECT_MODE__)
	 return ({*((vuint8*)(addr));});
#else
   uint8 data;
      *((vuint8*)IDM_AR) = addr >> 8;
      *((vuint8*)IDM_AR1) = addr;
	  if(addr &0x01) data = *((vuint8*)IDM_DR1);
	  else data = *((vuint8*)IDM_DR);

   return data;
#endif
}

void IINCHIP_WRITE(uint16 addr,uint8 data)
{
#if (__DEF_IINCHIP_ADDRESS_MODE__ == __DEF_IINCHIP_DIRECT_MODE__) 
	 *((vuint8*)(addr)) = data;
#else
    *((vuint8*)IDM_AR) = addr >> 8;
	  *((vuint8*)IDM_AR1) = addr;
	  if(addr &0x01) *((vuint8*)IDM_DR1) = data;
	  else *((vuint8*)IDM_DR) = data;
#endif
}

uint16   getMR(void)
{
   return (IINCHIP_READ(MR_) << 8 | IINCHIP_READ(MR));
}
void     setMR(uint16 val)
{
   *((volatile uint8*)MR_) = val >> 8;
   *((volatile uint8*)MR) = val & 0xff;
}
```

PS: I used the W5300 only in indirect mode.

### Reply 2 by sajjad kashkouie, 2018-06-02

hi…
i am using w5300 chip.and i have problem with addressing registers for initialization…
i dont understand what the Base Address(BS) is.
for example mentioned in datasheet, if BA = 0x8000, the IR Register’s address equals 0x8002.
while Address Bus hase only 10 bits.how can we show 0x8002 by 10 bits?

---

Source: https://maker.wiznet.io/forum/11087
