Arduino Mega 2560 + Sparkfun USB Host Shield


I would like to connect a USB jostick to my Arduino, but I don’t success having USB working.
This very simple code dosn’t work (it always write “Error” to the serial) :

#include <Usb.h>

USB usb;

void setup() {
  if(usb.Init() == -1) {
  } else {

void loop() {

Any suggestion ?

In addition to this test, after having tried quite a lot of things, I tried to communicate directly to the MAX3421E chip via SPI. The communication works, I success accessing the general purpose pins, but any USB request, for exemple sending a control packet to get the descriptor, returns “0x03” error in HSRLT register (wich should mean “reserved” ???).

Thanks for your help.



I have now a usb init working !

The problem was in Usb.h file. Line 61 indicates that for “Official Arduinos”, including Mega, the SS pin is #10, and RESET pin is #9. In my case, the “official” SS pin (even if it could be something else) is #53, and i pluged RESET to pin #42.

So after this update, I have the init working :

typedef MAX3421e<P6, P3>                MAX3421E;               // Black Widow
typedef MAX3421e<P9, P8>        MAX3421E;       // Teensy++ 2.0 & 1.0
#elif defined(BOARD_MEGA_ADK)
typedef MAX3421e<P53, P54>              MAX3421E;               // Arduino Mega ADK
// typedef MAX3421e<P10, P9>            MAX3421E;               // Official Arduinos (UNO, Duemilanove, Mega, 2560  <<--- Modified line
typedef MAX3421e<P53, P42>              MAX3421E;               // Official Arduinos (UNO, Duemilanove, Mega, 2560

This code now will only work with my configuration, but I can modify it in the future if necessary.



I have changed the part <P10,P9> to <P53,P9>

  1. Is keeping the P9 wrong?

I am currently not getting the required output with the P9 still in place.

Currently getting:

Circuits At Home 2011
USB Host Shield Quality Control Routine
Reading REVISION register… Die revision invalid. Value returned: 00
Unrecoverable error - test halted!!
0x55 pattern is transmitted via SPI
Press RESET to restart test

  1. Oleg’s code states that P9 is the INT pin. What is the INT pin? Where is it located on the Mega 2560?

Connect D9 of arduino mega to pin 9 of host shield. it will fix your problem. jumper between pin 7 and reset.