---
title: "WIZ811MJ Not Working"
url: "https://maker.wiznet.io/forum/10116"
markdown_url: "https://maker.wiznet.io/forum/10116/md"
type: "Forum topic"
category: "IO Modules"
author: "IvanDo78"
created: "2014-04-03T18:15:59+09:00"
last_activity: "2017-05-04T08:32:22+09:00"
language: "en"
views: 1182
replies: 3
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# WIZ811MJ Not Working

## Question

Asked by IvanDo78 on 2014-04-03 in IO Modules.

I need help with this module.
Im interfacing it with an AVR ATMega2560, and i cant make it work.

Im trying to initilize it but there is no response, there are my init functions:

void SPI_Init(void)
{
// Initial the AVR ATMega SPI Peripheral
// Set MOSI and SCK as output
DDRB = (1&lt;&lt;PINB2)|(1&lt;&lt;PINB1)|(1&lt;&lt;PINB0);
// Set MISO as input
//DDRB &= ~(1&lt;&lt;PINB3);

```
//Pull high W5100_CS and set W5100_CS as output
//DDRB |= (1<<PINB0);
PORTB |= (1<<PINB0);

// Enable SPI, Master Mode 0, set the clock rate fck/8
SPCR = (1<<SPE)|(1<<MSTR);
SPCR &= ~(1<<CPHA);
SPCR &= ~(1<<CPOL);
SPSR |= (1<<SPI2X);
```

}

void SPI_Write(unsigned int addr,unsigned char data)
{
// Activate the CS pin
PORTB &= ~(1&lt;&lt;PINB0);
// Start W5100 Write OpCode transmission
SPDR = WIZNET_WRITE_OPCODE;
// Wait for transmission complete
while(!(SPSR & (1&lt;&lt;SPIF)));
// Start W5100 Address High Bytes transmission
SPDR = (addr & 0xFF00) >> 8;
// Wait for transmission complete
while(!(SPSR & (1&lt;&lt;SPIF)));
// Start W5100 Address Low Bytes transmission
SPDR = addr & 0x00FF;
// Wait for transmission complete
while(!(SPSR & (1&lt;&lt;SPIF)));

```
// Start Data transmission
SPDR = data;
// Wait for transmission complete
while(!(SPSR & (1<<SPIF)));
// CS pin is not active
PORTB |= (1<<PINB0);
```

}

unsigned char SPI_Read(unsigned int addr)
{
// Activate the CS pin
PORTB &= ~(1&lt;&lt;PINB0);
// Start W5100 Read OpCode transmission
SPDR = WIZNET_READ_OPCODE;
// Wait for transmission complete
while(!(SPSR & (1&lt;&lt;SPIF)));
// Start W5100 Address High Bytes transmission
SPDR = (addr & 0xFF00) >> 8;
// Wait for transmission complete
while(!(SPSR & (1&lt;&lt;SPIF)));
// Start W5100 Address Low Bytes transmission
SPDR = addr & 0x00FF;
// Wait for transmission complete
while(!(SPSR & (1&lt;&lt;SPIF)));

```
// Send Dummy transmission for reading the data
SPDR = 0x00;
// Wait for transmission complete
while(!(SPSR & (1<<SPIF)));

// CS pin is not active
PORTB |= (1<<PINB0);
return(SPDR);
```

}

void W5100_Init(void)
{
printf(“Initializing W5100…\n\n”);

```
// Doing Hardware Reset
//DDRB |= (1<<PINB4);
//PORTB |= (1<<PINB4);

//PORTB &= ~(1<<PINB4);
//_delay_ms(5);
//PORTB |= (1<<PINB4);
//_delay_ms(10);

// Setting the W5100 Mode Register: 0x0000
// MR = 0b10000000;
SPI_Write(MR,0x80);
_delay_ms(1);
printf("Reading MR: %d\n\n",SPI_Read(MR));

printf("W5100 Initialized!\n");
```

}

void W5100_Config(void)
{
W5100_Init();
printf(“configuring W5100…\n\n”);

```
// Setting the W5100 Gateway Address (GAR): 0x0001 to 0x0004
printf("Setting Gateway Address %d.%d.%d.%d\n",Setup_Gateway[0],Setup_Gateway[1],Setup_Gateway[2],Setup_Gateway[3]);
SPI_Write(GAR + 0,Setup_Gateway[0]);
SPI_Write(GAR + 1,Setup_Gateway[1]);
SPI_Write(GAR + 2,Setup_Gateway[2]);
SPI_Write(GAR + 3,Setup_Gateway[3]);
_delay_ms(1);
printf("Reading GAR: %d.%d.%d.%d\n\n",SPI_Read(GAR + 0),SPI_Read(GAR + 1),SPI_Read(GAR + 2),SPI_Read(GAR + 3));

// Setting the W5100 Source Address Register (SAR): 0x0009 to 0x000E
printf("Setting Source Address %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",Setup_MAC[0],Setup_MAC[1],Setup_MAC[2],Setup_MAC[3],Setup_MAC[4],Setup_MAC[5]);
SPI_Write(SAR + 0,Setup_MAC[0]);
SPI_Write(SAR + 1,Setup_MAC[1]);
SPI_Write(SAR + 2,Setup_MAC[2]);
SPI_Write(SAR + 3,Setup_MAC[3]);
SPI_Write(SAR + 4,Setup_MAC[4]);
SPI_Write(SAR + 5,Setup_MAC[5]);
_delay_ms(1);
printf("Reading SAR: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n\n",SPI_Read(SAR + 0),SPI_Read(SAR + 1),SPI_Read(SAR + 2),SPI_Read(SAR + 3),SPI_Read(SAR + 4),SPI_Read(SAR + 5));

// Setting the W5100 Sub Mask Address (SUBR): 0x0005 to 0x0008
printf("Setting Sub Mask Address %d.%d.%d.%d\n",Setup_DNSMASK[0],Setup_DNSMASK[1],Setup_DNSMASK[2],Setup_DNSMASK[3]);
SPI_Write(SUBR + 0,Setup_DNSMASK[0]);
SPI_Write(SUBR + 1,Setup_DNSMASK[1]);
SPI_Write(SUBR + 2,Setup_DNSMASK[2]);
SPI_Write(SUBR + 3,Setup_DNSMASK[3]);
_delay_ms(1);
printf("Reading SUBR: %d.%d.%d.%d\n\n",SPI_Read(SUBR + 0),SPI_Read(SUBR + 1),SPI_Read(SUBR + 2),SPI_Read(SUBR + 3));

// Setting the W5100 IP Address (SIPR): 0x000F to 0x0012
printf("Setting IP Address %d.%d.%d.%d\n",Setup_IP[0],Setup_IP[1],Setup_IP[2],Setup_IP[3]);
SPI_Write(SIPR + 0,Setup_IP[0]);
SPI_Write(SIPR + 1,Setup_IP[1]);
SPI_Write(SIPR + 2,Setup_IP[2]);
SPI_Write(SIPR + 3,Setup_IP[3]);
_delay_ms(1);
printf("Reading SIPR: %d.%d.%d.%d\n\n",SPI_Read(SIPR + 0),SPI_Read(SIPR + 1),SPI_Read(SIPR + 2),SPI_Read(SIPR + 3));

// Setting the W5100 RX and TX Memory Size, we use 2KB for Rx/Tx 4 channels
printf("Setting W5100 RMSR and TMSR\n\n");
SPI_Write(RMSR,0x55);
SPI_Write(TMSR,0x55);
printf("W5100 Configured!\n");
```

}

Im using this code from a web blog, but dont work for me and i dont know where is the problem.
I have analized de SPI bus and for me all was ok, i can send a capture of the bus.

Help please!!!

Thanks

## Replies

### Reply 1 by IvanDo78, 2014-04-04

After your adding your modification, im having back response from the wiz811 module, but there is somothing wrong, i can’t setup properly the GWR,SUBR,SHAR and SIPR registers.
Here s a screenshoot of my logic analyzer.

[![](https://maker.wiznet.io/forum_uploads/wiznet/original/1X/bbbbf17f17c0ffcf96cc1c0be7e83fa5103d05b4.png) 1272×754 21.6 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/1X/bbbbf17f17c0ffcf96cc1c0be7e83fa5103d05b4.png)

[![](https://maker.wiznet.io/forum_uploads/wiznet/original/1X/2138e52a4e7d310c6be579b7de7ffdb5023361af.png) 516×756 12.3 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/1X/2138e52a4e7d310c6be579b7de7ffdb5023361af.png)

[![](https://maker.wiznet.io/forum_uploads/wiznet/original/1X/28d6f9bc95055158086f91a9f6a72e4c276b2a8e.png) 517×763 12.6 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/1X/28d6f9bc95055158086f91a9f6a72e4c276b2a8e.png)

### Reply 2 by IvanDo78, 2014-04-04

More screenshoots…

[![](https://maker.wiznet.io/forum_uploads/wiznet/original/1X/9cbcbab6f9d533b7534099213c6f35c59904107f.png) 1715×763 25.9 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/1X/9cbcbab6f9d533b7534099213c6f35c59904107f.png)

[![](https://maker.wiznet.io/forum_uploads/wiznet/original/1X/92d456ab0fb1619494e317269e9155f899dab0b9.png) 1462×745 21 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/1X/92d456ab0fb1619494e317269e9155f899dab0b9.png)

[![](https://maker.wiznet.io/forum_uploads/wiznet/original/1X/ce66e1d328d4fe795b3408a2750d395fc50ba620.png) 1496×748 21.3 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/1X/ce66e1d328d4fe795b3408a2750d395fc50ba620.png)

### Reply 3 by IvanDo78, 2014-04-08

There is a problem in my /RESET line, and in the logical level of MISO,MOSI,SS,SCK.

For the issue with the /RESET line i have put a 10k resistor, and for the logical level issue, y made a logical converter 3V3 to 5v ,5V to 3V3 with four 2N7000 and a few resistors.
In the Wiz5100 Datasheet says that the IC is 5V tolerant, but in my case doesn’t work without adapt the levels.

Now all is working ok for me.

Thanks for your replies!!!

---

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