Go Down

Topic: Teensy++2.0 with Circuits@Home USB Host Mini (Read 18515 times) previous topic - next topic

colmo

Hi,

I'm trying to get a Circuits@Home USB Host Mini working with the Teensy++2.0 board.. but it's not working.

Thus far, I've done the following:
- soldered both boards onto some perfboard (since they connect via SPI, I could't just use the usual breadboard solution).
- configured the USB host mini board to provide 5v to the USB VBUS (to allow bus-powered peripherals)by cutting the VBUS trace, and by soldering a wire between the VBUS pad and the RAW pin (which is connected to a 5v power source)
- Included felis's USB Host library in Arduino 0022, and made a change to Max3421e_constants.h, in place of the piece that now lives in the "else" statement.  The aim is to support the pin numbering on the AT90USB1286 in the Teensy++2.0.

<code>
#if defined(__AVR_AT90USB1286__)
  #define SS_PIN  20
  #define SCK_PIN  21
  #define MOSI_PIN  22
  #define MISO_PIN  23

  #define MAX_SS    20
  #define MAX_INT   19
  #define MAX_GPX   0
  #define MAX_RESET 10
#else
  //the case for everything other than the Teensy++ 2.0
  #define MAX_SS    10
  #define MAX_INT   9
  #define MAX_GPX   8
  #define MAX_RESET 7
#endif
</code>

I've run the "board test" example that comes with the USB Host library, but it fails, with the following:

<results>
Circuits At Home 2010
USB Host Shield QC test routine

Press any key to continue...

Reading REVISION register...Die revision invalid. Value returned: FF
Test FAILED*!*
Test Halted.
0x55 pattern is being transmitted via SPI to aid in troubleshooting
Press RESET to restart test
</results>

The actual soldered connections between the Teensy++2.0 and the USB host mini board are the following:

<connections>
USB Mini Breakout board (r1.1)
--starting at the bottom left, moving about the board counterclockwise

1=SS - connected via 3.3v LDO to pin 20 (SS) on Teensy++2.0 (3.2v measured here)
2=MOSI - connected via 3.3v LDO to pin 22 (MOSI) on Teensy++2.0 (3.21v measured here)
3=MISO - connected directly to pin 23 (MISO) on Teensy++2.0 (0v measured here)
4=SCK - connected via 3.3v LDO to pin 21 (SLCK) on Teensy++2.0 (0v measured here on input side of LDO, and the ground connection to the LDO is ok)
5=no connection
6=no connection
7=no connection
8=no connection
9=3.3v, connected, via 3.3v LDO to 5v (verified 3.23v)
10=no connection
11=GND, connected to GND on Teensy++2.0
12=RAW(5V), connected to VCC on Teensy++2.0 (verified 4.88v)

--skipping all the GPIN, and GPOUT pins, which are not connected to anything

--starting at the top right, moving counterclockwise again
13=no connection
14=no connection
15=RESET - connected via a 3.3v LDO to pin 10 on Teensy++2.0 (3.21v measured here)
16=GND (valid ground connection)
17=no connection
18=no connection
19=no connection
20=no connection
21=no connection
22=no connection
23=no connection
24=INT - connected to pin 19 on the Teensy++2.0 (measures 3.23v)

- the VBUS trace has been cut on the USB Host Mini
- I've soldered a wire between the VBUS pad, and the RAW pin (to provide 5v to the USB peripheral, which will be bus powered)
</connections>

So, in summary, it's not working..

And finally, some observations / questions:
1) In Max3421e_constants.h I'm confused why, on the Arduino Mega, MAX_SS != SS_PIN (10 != 53), whereas on the Duemilanove, MAX_SS ==SS_PIN (10 == 10).  Also, in one of the pages on circuits@Home, when Oleg describes what changes need to be made when the SS pin needs to move, only MAX_SS is documented as needing to change, but not SS_PIN, so this makes me think the two pins serve different functions (I originally assumed they were just two different names for the same thing). In my case so far, I have both SS_PIN and MAX_SS == 20 (the SS pin on the Teensy++2.0).  I'm beginning to think that this might be an issue, but I don't know how to determine the correct pin numbers.  Can anyone explain the differences between SS_PIN and MAX_SS?
2) Is SPI going to work ok over some soldered connections on perfboard, or will there be too much stray capacitance, same as on a breadboard?
3) Do the measured voltages look ok for SPI?
4) Has anyone else gotten this combination (Teensy++2.0 with Circuits@Home USB Host Mini) working?  If so, can they post details of pins used, etc?

I'm new to micro-controllers, so if you're assuming that I've first done / checked all the obvious things, please don't :)

Colm

pjrc

I'm not sure why it's not working.  Everything you wrote appears correct, at least on initial reading and without digging into the code.

I ordered one of those boards just now.  When it arrives, I'll hook it up and figure out how to get it working.

SPI ought to work fine with ordinary wires of reasonable length (eg, under a few inches or 10 cm).  Without digging into the code (and making some assumptions without working hardware on my bench) I can't verify what the specific DC voltages ought to be... as that depends on the specific SPI configuration used, and maybe other details.

There's not a lot more I can do until the board arrives, other than let you know I definitely did purchase one and when it gets here I'll investigate.

colmo

Hi Paul,

Thanks for this.  I was hoping that someone would spot something obviously silly that I had missed. The Teensy (2.0++) has worked pretty much first time with all the other hardware I've tried to interface it with, until I tried this board, so I guess I was due a problem or two.

Funnily enough, I did the same as you did a few hours ago: I ordered an Arduino Pro Mini 3.3v to plug directly into the USB host board, to check that the USB host mini works in its native form.  It would be great to get the USB host board working with the Teensy though, because of its decent sized program space (130k, IIRC).. I'm already up to about 14k, and I have some other stuff that I still need to do, so the Teensy is about the only device that I'm aware of that can fulfil all my requirements at the same time.

Looking forward to seeing what you come up with, when you get the hardware.  If I find anything out in the meantime, I'll post it here.

Colm

colmo

Update. There's a new version of the USB host library available as of yesterday:

http://www.circuitsathome.com/mcu/usb-host-shield-library-version-2-0-released

I haven't tried this yet to see if it makes any difference, but i should get a chance to look at this later today or over the weekend with my Teensy++2.0/USB Host mini hardware combination.

felis

Pin assignment in new library is different, it is now done on line 38 in Usb.h, see here -> https://github.com/felis/USB_Host_Shield_2.0/blob/master/Usb.h . Arduino pins are named P[number], standard AVR pins are named Pa[0-7], Pb[0-7], etc. , see avrpins.h, line 212 and below -> https://github.com/felis/USB_Host_Shield_2.0/blob/master/avrpins.h

pjrc

I'm planning to look at this when my hardware arrives.  It hasn't yet...

pjrc

It arrived this afternoon, only minutes after I posted that last message.   ;)

I've been studying the 2.0 code this afternoon.  So far, I've added pin definitions at the end of avrpins.h and more cpu types to usbhost.h at line 47.  The hardware abstraction layer and its usage looks very good (if only the Arduino core were designed this well...) so I'm feeling pretty good.  So far, I've not touched line 38 in Usb.h, so I'll just use pins 10 and 9 for consistency.

How to connect the USB host power is a bit of a mystery so far.  I'm looking at the eagle file.  It has "Aug.21,2010" in the silk screen, but the board I received has "Oct.12,2010" printed.  The changes appear to be 3 configuration jumpers, which are a nice feature, and the extra pads nearby.

As wired, at least as nearly as I can tell using my ohm-meter, the USB host power is connected to the +3 volt power.  For use with a Teensy converted to 3 volts, but powered from a USB cable supplying 5 volts, I think the best option would be the cut the host power jumper and solder a wire from the 5 volt pad on the bottom of the Teensy board to the host power pad that becomes isolated if that jumper is cut.  Maybe?  Of course, this isn't really nice for mounting either board in a DIP socket.  The 5V power power pad is on the bottom side of Teensy, and the host power pad on the USB Mini Host Shield is so close the USB host connector shell that I'm not sure I can solder a wire in place without shorting the power.

I suppose I'll try it first with 3 volts to the USB host power.  Do many USB devices work with only 3.3 volts?

Will post again once I've actually got it hooked up....

I didn't see the board test example in version 2.0.  Did I miss it, or is it available somewhere for 2.0?

pjrc

Ok, here's what I've got so far.  I've modified both version 1 and 2.  Neither has much testing yet.  Here's the code.

http://www.pjrc.com/teensy/beta/USBHostShield_25jun11_try1.zip

Be careful to copy only one version at a time into your Arduino IDE's libraries directory!

Here's how I connected the wires.  I'm pretty sure this is the correct wiring needed to make it work.

Code: [Select]
Host Shield     Teensy          Teensy++
-----------     ------          --------
SS              10              10
INT             9               9
MOSI            2               22
MISO            3               23
SCK             1               21
Reset           Vcc             Vcc
+3.3V           Vcc (MCP1825)   Vcc  (must use MCP1825)
GND             GND             GND


On version 1, I was able to get the board test to run.  Here's what I got:

Code: [Select]
Circuits At Home 2010
USB Host Shield QC test routine

Press any key to continue...
Reading REVISION register...Die revision 03
Test PASSED
Checking GPIO lines. Install GPIO loopback adapter and press any key to continue...GPIO read/write mismatch. Write: 0 Read: FF

GPIO check failed. Make sure GPIO loopback adapter is installed
SPI test. Each  '.' indicates 64K transferred. Stops after transferring 1MB (16 dots)
................
Test PASSED
Oscillator start/stop test. Oscillator state is ON
Setting CHIP RESET. Oscillator state is OFF
Clearing CHIP RESET. PLL is stable. Time to stabilize - 521 cycles
Test PASSED
USB Connectivity test. Waiting for device connection...


In version 1, I added the SPI pins, tweaked the initialization to turn on pullups on INT and GPX, and changed the reset function to wait longer (it was timing out waiting for the PLL to lock...)  That was enough to get the board test to run, at least as shown above.

In version 2, I added pin definitions in avrpins.h and cpu definitions in usbhost.h at line 47.  So far I haven't been able to get the board test to run in version 2.  It seems the API is very different.

My first attempt at using a USB device failed, but I suspect it doesn't like the 3.3 volt power.  Will try more tests soon.  But if you want to give it a try, here's the pin connections and code tweaks so far.

felis

Quote
As wired, at least as nearly as I can tell using my ohm-meter, the USB host power is connected to the +3 volt power.  For use with a Teensy converted to 3 volts, but powered from a USB cable supplying 5 volts, I think the best option would be the cut the host power jumper and solder a wire from the 5 volt pad on the bottom of the Teensy board to the host power pad that becomes isolated if that jumper is cut.  Maybe?  Of course, this isn't really nice for mounting either board in a DIP socket.  The 5V power power pad is on the bottom side of Teensy, and the host power pad on the USB Mini Host Shield is so close the USB host connector shell that I'm not sure I can solder a wire in place without shorting the power.


You can do 5V to VBUS the following way: cut the VBUS jumper and solder a wire to VBUS pin on USB connector on the bottom side. The pad is close to USB connector shell but not that close - many people soldered there with success - if you get too big of a solder bump there, just clean it away with a wick.

Quote
I suppose I'll try it first with 3 volts to the USB host power.  Do many USB devices work with only 3.3 volts?


Most digital cameras would work with 3.3V on VBUS. Also, try USB sticks - I'm using one during board test of 3.3V boards and it works just fine.

Quote
I didn't see the board test example in version 2.0.  Did I miss it, or is it available somewhere for 2.0?


Board test for 2.0 is in the works.

felis

Paul,

Do you mind if I include your modifications in my distro?

Oleg.

pjrc

Yes, of course, please include my modifications.  :-)

I was planning to write a web page documenting how to hook this up, and put the modified copy on there, if that's ok?

I'm still doing more testing and trying to get a device to work....




felis

Of course it's OK, I'm looking forward to it.

pjrc

I got a device to communicate.  The "problem" turned out to be not enough capacitance on the USB host power line.  Plugging in a device would cause the power to drop for a brief moment, which resets the Teensy.  Adding a 100 uF capacitor fixed the problem.

Oleg, could you please email me, paul at pjrc dot com.  Thanks.  :)


colmo

Wow. You guys have been busy! I've just finished up some other work that I had to do, and I wasn't paying attention to the forum, so I'll try this out tomorrow, assuming I have some suitable capacitors lying about somewhere.

Thanks very much for all the hard work!

Colm

Go Up