Pages: [1]   Go Down
Author Topic: USB Host Shield with Mega1280  (Read 1177 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi guys,

Has anyone tried getting the Sparkfun USB Host Shield to work with Mega 1280?

Currently, my aim is to interface a 2D Unitech MS337 Barcode Scanner with the Mega 1280. I intend to use the code from Schogini but the USB Host shield is not working right. I am using Oleg's codes.

It keeps giving "Error: OSCOKIRQ failed to assert", though I have defined "define MAX_GPX 7 define MAX_RESET 8" and power the shield by external power supply.

I understand the SPI pins on Mega1280 are 50 (MISO), 51 (MOSI), 52 (SCK), 53 (SS). Do I need to connect these to pins 13,12,11,10 on USB Shield since:

#if defined(__AVR_ATmega1280__)
  #define SCK_PIN   52
  #define MISO_PIN  50
  #define MOSI_PIN  51
  #define SS_PIN    53
#if  defined(AVR_ATmega168) || defined(AVR_ATmega328P)
  #define SCK_PIN   13
  #define MISO_PIN  12
  #define MOSI_PIN  11
  #define SS_PIN    10

Am I missing something? Would greatly appreciate your help.
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 92
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Did you modify the shield? Since the SPI pins on the mega are in a different location, you need to either rewire the shield. From circuits@home:

Quote
If you are planning to use this shield with one of the “Big” Arduinos, like Mega or 2560, SPI signals would have to be rerouted, i.e., pins 13,12,11 of the shield should be connected to pins 50,52,51 of the Mega.

If you already did this, note that the code assumes that you rewire SS (slave select) to pin 53, but the above statement tells you to only rewire miso, mosi and clock. Therefore, if you followed this you are left with SS still connected to pin 10. The code should therefore be:

Code:
#if defined(__AVR_ATmega1280__)
  #define SCK_PIN   52
  #define MISO_PIN  50
  #define MOSI_PIN  51
  #define SS_PIN    10

note that last line.

Alternatively you can write some code to do software SPI by manually bit-banging pins 11-13, which should work too and isn't complicated. I used this to get an SPI-driven LCD shield working on the mega:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1253831901

Let me know if this works for you.
« Last Edit: January 05, 2011, 01:45:29 pm by niels.brouwers » Logged

Louisville, CO
Offline Offline
Full Member
***
Karma: 2
Posts: 174
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

FYI,

The code in USB Host library supports soon to be released version 2.0 of the shield (see picture). It gets SPI via ICSP connector, which happens to be in the same place on all official Arduinos and also many clones. The rest of the signals are in the same place (pins 9 and 10) since these pins are on the same header on all Arduino variants also.

Oleg.

Logged

/felis

0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Inopia & Felis,

Thank you for your replies and updates.

I left the SPI definition as per the original code, rerouted the wires but left 10 alone, and the examples worked alright now.

Though I am still trying to get the 2D barcode scanner to work. Probably need to look into the library.

Thx guys!!
Logged

Pages: [1]   Go Up
Jump to: