Open Hardware creator

ZG2100 Based WiFi Shield

Can CuHead WiFi Shield be used with Arduino Mega?

Hits:  UpdateTime:2012-02-17 23:31:23  【Printing】  【Close

Can CuHead WiFi Shield be used with Arduino Mega?


To all Arduino Mega Users:

To make the WiShield work on mega follow the NKC tutorial on wiring up the Ethernet shield

and make the following changes to spi.h (in hardware\libraries\wishield):

#define SPI0_SS_BIT                                    BIT0            
#define SPI0_SCLK_BIT                              BIT1
#define SPI0_MOSI_BIT                              BIT2
#define SPI0_MISO_BIT                              BIT3
#define SPI0_Init()                                    PRR0 = 0x00;\
                                                       DDRB  |= SPI0_SS_BIT|SPI0_SCLK_BIT|SPI0_MOSI_BIT|LEDConn_BIT;\
                                                     DDRB  &= ~SPI0_MISO_BIT;\
                                                     PORTB = SPI0_SS_BIT;\
                                                     SPCR  = 0x50;\
                                                     SPSR  = 0x01

#define ZG2100_CS_BIT                              BIT0
#define LEDConn_BIT                                      BIT5            




 the Mega not only remapped the SPI pins, it also remapped the interrupt pins. The ZeroG board triggers an interrupt when it needs the host to do something. This is why the WiShield would init, and then nothing else. If you attach a scope or a LED to the WiShield interrupt pin (pin2/int0), you can see it going low but never getting serviced.

On the Duemilanove, Arduino Pin 2 goes to INT0/PD2 on the ATMega328. On the Mega, Arduino Pin 2 goes to PE4, which is not an interrupt at all. 

(1) Bend out pin 2 on the WiShield similar to how pins 10,11,12,13 are bent out.
(2) Jumper this pin on the WiShield to pin 21 on the Arduino Mega.
(3) In "WiServer.cpp" and "WiShield.cpp" change "attachInterrupt(0, zg_isr, LOW);" to "attachInterrupt(2, zg_isr, LOW);". This may be counterintutive, but from the documentation, it seems the Arduino development environment maps interrupt pin 2 to 21. See for details.

For extra credit, if you don't like mangling the pins on your beautiful WiShield, connect the jumpers and turn pins 2,10,11,12,13 into high-impedance inputs. Note this means you can't use them for other purposes but they can remain electrically connected.

pinMode(2, INPUT);
pinMode(10, INPUT);
pinMode(11, INPUT);
pinMode(12, INPUT);
pinMode(13, INPUT);



Live Help

LinkSprite Technologies, Inc.
Add:1067 S Hover St, Unit E-186,Longmont, CO 80501


720-204-8599 (MST: 9:00am-5:00pm)

 720-279-0774 (MST: 6:00pm- 3:00am)


Technical questions:



About us|Enterprise News|Learning Cent|Download|Guestbook|Feedback|Article|Member|Contact|Search|Sitemap|Open Hardware|Admin
Powered by MetInfo 4.0 ©2008-2017