ATMEGA 644 won´t work with WIZNET5100 WIZ812MJ

Hello,

I´m new here and have a little problem with my ethernet.

I use the Atmega 644 with the Duino Bootloader http://bit.ly/dK8zCf ,the core files from http://bit.ly/gr0xH9 and the Arduino IDE 022.

The 644 is on a breadboard wired with the WIZ812MJ and a Duemilanove to programm it.

The WIZ812MJ works with the Duemilanove 328P, i tested the Webserver example.

But it didn´t work with the Atmega 644, i read that there could be a Pin setting problem with slave select but i doesn´t really understand the code from the libaries and the core files to fix it myself.

Any ideas?

PS: sorry for my english :wink:

Are you wiring the Wiz812 module to the ISP connector, or to the "shield compatible" pins on the Duino644 ?
The wiznet libraries use the hardware SPI module of the AVR, so you MUST connect the 812 to the pins that the hardware SPI module uses, which is NOT guaranteed to be present on the same shield pins across Arduino versions. (For example, the Arduino MEGA does NOT work with the old wiznet-based ethernet shield for exactly this reason. The new wiznet shield gets the SPI signals from the ISP connector instead to solve this problem.)

Thats a bit strange, because at least in the Atmega1280 the SPI pins are connected to the USART0 and not to the SPI pins.
Just grab the Atmega644 datasheet and se where the the hardware SPI pins are.

Thanks for the answer but i don´t think this is the problem. The Atmega 644 use the same pins for ISP as for Ethernet SPI, it´s like the Atmega 328P on the Arduino board. Am I wrong ?

The Datasheet from the WIZ812MJ say I should connect to SS MISO MOSI SCLK and it does work with the 328P in this way, so the connection is probably right.

http://dl.dropbox.com/u/9937069/644.JPG

http://dl.dropbox.com/u/9937069/WISNET.JPG

I need the USART, so it would be a problem to use it for Ethernet.

First, in what board is that Atmega644, what I said is that you need to use the SPI pins of the Atmega644, grab its datasheet and see where they are!

I read the Datasheet before wireing the Atmega 644. The WIZ812MJ ist wired with the Hardware SPI Pins of the 644.

The 644 is on a Breadboard, wired with the Duemilanove to program it and is wired with the WIZ812MJ.

So nobody has a suggestion besides wrong wireing.

Than another question, does anybody have a working Ethernet with a Atmega 644 ?

In the best case a working Ethernet with the WIZnet 5100.

(Hardwireing the SS Pin to GND don´t work with a WIZnet Chip)

So nobody has a suggestion besides wrong wireing.

Nope. Sorry...

(studies photograph)
Um, are you trying to power the Wiznet from the 3.3V output of your duemilanove? I don't think it's capable of providing enough current! I don't see a spec in my module datasheet, but the W5100 chip itself says 138 to 183 mA, and the duemilanove 3.3V (provided by the FTDI chip) is only good for about 50mA....

Hey,

I have had my WIZ812MJ working fine with my 644P.
I have also had it working fine with my Arduino Duemilanove.

It was about 6 months ago I did it though. I am currently designing a new set of boards which will be using it, so I will be getting back to the software in the next month.
From memory, it uses the standard SPI hardware pins including the hardware Chip Select pin.

If you want to move away from this, I think you need to modify the SPI library as it is hardcoded in there based on the pins_arduino.h file.
To keep it intact, its probably easiest to duplicate the SPI library and rename it specifically for your Ethernet, and change the cpp file to use a differernt SS pin.

I am by no means an expert on this. I have had it going however, enough to test the Wiznet board with the Micro, and determine that 'yes, it works' and therefore I have used it in my design.

Are you using the Sanguino bootloader for the 644?
That is what I use and it works fine. If you are using someone elses, then you may need to check that they have the correct configuration for the SPI pins in their pins_arduino.h file.

Just an idea - hope that is of some help

Thanks for the answers

@ westfw

It works fine with the 3.3V from the Duemilanove board thats no problem.

@ WanaGo

I have the option to use the 644P instead of the 644, or better said I ordered it already for testing. I used the Sanguino bootloader first so I can change back (I have the Atmel AVRISP MK2 to burn the bootloader).
Would it be possible for you to post your modifed files for the 644P or to send it by email ?

It works fine with the 3.3V from the Duemilanove board thats no problem.

It is a problem. It may have worked once, but it's WAY out of spec.

Well, maybe not WAY out of spec, but certainly somewhat out of spec:

Way out of spec with respect to the current that the 3.3V pin on duemilanove is supposed to be able to provide (50mA) compared with the current that the Wiznet Module is supposed to use (130mA+)

The WIZ812MJ did work with the Atmega 328P in the duemilanove borad on the 3.3V . But I see, I had more luck than brain, that my devices don´t die.

I have to confess that the power LED on the WIZ812MJ died while the tests.
This configuration with the duemilanove borad is my testing area. In the end I put the Atmega 644 and the WIZ812MJ device on a other board with a extra powerregulation (LM 317) for the WIZ812MJ.

But thanks for washing my head. I hope my duemilanove borad isn´t to angry about it :wink:

Sig644:
@ WanaGo

I have the option to use the 644P instead of the 644, or better said I ordered it already for testing. I used the Sanguino bootloader first so I can change back (I have the Atmel AVRISP MK2 to burn the bootloader).
Would it be possible for you to post your modifed files for the 644P or to send it by email ?

Hey sorry for the delay in reply.
I didnt create any modified files - I only tested it using the standard SPI library. As mentioned above, I have only done enough work with the software to prove that it works and can be used in the hardware design. I havent gone into detail of making software that I will actually use as a final product yet.

I too used the Wiznet with the Duemilanove 3.3V and it worked ok. No doubt out of spec like mentioned but it did work for the few minutes I needed it for. The 130mA or whatnot stated in the spec may be the case at full speed, but since the Arduino cant transmit over Ethernet at the full speed, maybe it doesnt end up using the full power requirement? Just guessing and I am probably totally wrong, but does sort of make sense to me that if the Wiznet isnt having to switch its output flat out then maybe it wont use the full power as per the spec. Either way, it worked for a few minutes for me.

Hopefully you can get yours working on the 644(P) etc.

Regards
WanaGo

Did you have any luck with this in the end?

I have just received the prototype boards back from the printer and have populated them, and am now just attempting to get some test code working for the Wiznet module.

I dont have the exact computer setup I had when I did my first test, so I have started again with IDE 22.
I have downloaded the arduino-extras zip file that Mark S produced on his website (www.avr-developers.com) as that has the core files for the 644P.
I compared them against the Sanguino files and there are decrepencies. I couldnt even get the Sanguino core files to compile the Ethernet library.

I then looked in the pins_arduino.h (and .c) files, and found there was no reference to the MISO, MOSI, CSK, SS for the 644P configuration, as it looks like the SPI library uses these variable declarations.

here are some examples:

In the SPI library, it has the following code:

void SPIClass::begin() {
  // Set direction register for SCK and MOSI pin.
  // MISO pin automatically overrides to INPUT.
  // When the SS pin is set as OUTPUT, it can be used as
  // a general purpose output port (it doesn't influence
  // SPI operations).
 
  pinMode(SCK, OUTPUT);
  pinMode(MOSI, OUTPUT);
  pinMode(SS, OUTPUT);
  
  digitalWrite(SCK, LOW);
  digitalWrite(MOSI, LOW);
  digitalWrite(SS, HIGH);

It refers to the SCK, MOSI and SS variables.
I then looked in the pins_arduino files in the modified core files from Mark S, and found this entry in the pins_arduino.h file:

#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
const static uint8_t SS   = 53;
const static uint8_t MOSI = 51;
const static uint8_t MISO = 50;
const static uint8_t SCK  = 52;
#else
const static uint8_t SS   = 10;
const static uint8_t MOSI = 11;
const static uint8_t MISO = 12;
const static uint8_t SCK  = 13;
#endif

It didn't have any listing for the 644P.
I added in this part, however still no joy:

#elif defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__)
const static uint8_t SS   = 30;
const static uint8_t MOSI = 5;
const static uint8_t MISO = 6;
const static uint8_t SCK  = 7;

SS = 30 above is how I have the Ethernet Board wired in my setup. Very crude way to do it, as all SPI devices would therefore use this, however I dont see the SPI library as being very accomidating for this anyway, as the SS is hardcoded inside the library. I am not experienced enough to know the best method to make the SPI library suitable for using multiple SPI devices at once.
Either way, I have hard coded my SS to be 30 at the moment, so I am guessing that the SPI library will therefore use this value of 30.

But as mentioned, still no joy yet.

I really cannot recall how I got it working when I did my first testing, and am now actually starting to doubt if I did infact carry out this testing on the 644P...
My memory is quite poor.

If anyone has any input I would love to hear.
I have already emailed Mark to see if he can assist.

Thanks

I have had a bit more of a look, trying to understand how this works.

In the Ethernet Library, there is the W5100 files that refer to the SPI.h file. So I am assuming this is the link that joins the Ethernet library to the SPI library.

Inside this file, near the bottom are the following lines, and I think these may be related to the problem, if not the cause (additional to the already mentioned).

private:
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
  inline static void initSS()    { DDRB  |=  _BV(4); };
  inline static void setSS()     { PORTB &= ~_BV(4); };
  inline static void resetSS()   { PORTB |=  _BV(4); };
#else
  inline static void initSS()    { DDRB  |=  _BV(2); };
  inline static void setSS()     { PORTB &= ~_BV(2); };
  inline static void resetSS()   { PORTB |=  _BV(2); };
#endif

I am not yet sure what to put here for the 644 and 644P, however I will give it some thought. I think its currently trying to do something incorrect with the SS bit, so a new number needs to be inserted instead of 2 or 4 above in a new #elif statement. I am not sure what that is at this point though, not code that I have had to try and interpret before.

Actually, I think the value in your case should be 16.
In my case, because I am not using a standard SS pin (using Digital 30, or PA1), mine should be 2 - but of PortA.
16 in Binary when mapped to Port B, is PB4 which is the SS pin.
2 in Binary when mapped to Port A, is PA1 which is my custom SS pin.

INCORRECT ABOVE SO EDITED:

Digital 30 for me is PA1, which is _BV(1), not 2 as mentioned above.
PB4 for you, which is _BV(4), not 16 as mentioned above.

I will test this once I have given my son his bath etc - :slight_smile: Hopefully this is all that is required.

So you maybe need to do this:

EDITED BELOW TOO

private:
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
  inline static void initSS()    { DDRB  |=  _BV(4); };
  inline static void setSS()     { PORTB &= ~_BV(4); };
  inline static void resetSS()   { PORTB |=  _BV(4); };
#elif defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__)
  inline static void initSS()    { DDRB  |=  _BV(4); };
  inline static void setSS()     { PORTB &= ~_BV(4); };
  inline static void resetSS()   { PORTB |=  _BV(4); };
#else
  inline static void initSS()    { DDRB  |=  _BV(2); };
  inline static void setSS()     { PORTB &= ~_BV(2); };
  inline static void resetSS()   { PORTB |=  _BV(2); };
#endif

and I need to try this:

private:
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
  inline static void initSS()    { DDRB  |=  _BV(4); };
  inline static void setSS()     { PORTB &= ~_BV(4); };
  inline static void resetSS()   { PORTB |=  _BV(4); };
#elif defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__)
  inline static void initSS()    { DDRA  |=  _BV(1); };
  inline static void setSS()     { PORTA &= ~_BV(1); };
  inline static void resetSS()   { PORTA |=  _BV(1); };
#else
  inline static void initSS()    { DDRB  |=  _BV(2); };
  inline static void setSS()     { PORTB &= ~_BV(2); };
  inline static void resetSS()   { PORTB |=  _BV(2); };
#endif

Time will tell

Cheers
James

Ok no that didnt work.

I think the value in your case should be 16.

The _BV(n) syntax converts a "bit number" to a binary value, and since the AVR is an 8 bit architecture, it won't ever be more than 7 for accessing bits in an IO port. The actual definition is:#define _BV(n) (1<<(n))

So for PB4 (which is a bit number as well), you should try:inline static void initSS()    { DDRB  |=  _BV(PB4); };
and for PA1 you can use inline static void initSS()    { DDRA  |=  _BV(PA1); };