chipKIT® Development Platform

Inspired by Arduino™

How to use the chipKIT as a USB host?

Created Sun, 31 Jul 2011 18:36:44 +0000 by TECH GEEK


TECH GEEK

Sun, 31 Jul 2011 18:36:44 +0000

I've been wondering how I can get a chipKIT Max32 to work as a USB host?


rtestardi

Sun, 31 Jul 2011 19:45:08 +0000

What kind of USB host do you want to be?

There won't be support for this in the Arduino code path, but there are a number of USB host stacks available.

Microchip has one you can use with MPLAB, and I even have one you can use written from scratch at the bottom of the following page, in the skeleton project -- StickOS can be configured to log "print" statements to a USB flash drive using that library internally... See: http://www.cpustick.com/downloads.htm

I can also answer most questions about how the USB SIE works, if you want to write driver code from scratch.

-- Rich


ron.dunn

Sun, 31 Jul 2011 23:32:14 +0000

Dumb question here, but how do you handle the physical interface? I've not seen a board (not just chipKit) with a receiver for a USB key.

Ron.


GeneApperson

Mon, 01 Aug 2011 00:54:21 +0000

@Ron

The microcontroller on the board must have a USB controller capable of doing hosting. The PIC32MX320 (on the Uno32) does not. The PIC32MX795 (on the Max32) does. In the AVR world, the AT90USB647 is one that can do USB hosting. Alternatively, there must be some other chip that the microcontroller can talk to (e.g. on a shield) that is capable of USB hosting. I think that Maxim and Cypress have USB controller chips that can be accessed via a serial interface (I'm not sure if they can do hosting, though).

Then, you need the USB controller hooked up to an appropriate connector. This is generally a standard USB A receptacle, although it could be a mini or micro AB receptacle. A shield that supports USB hosting would pretty much have to have a USB receptacle connector on it, unless it was for some proprietary interface.

Gene Apperson Digilent


ron.dunn

Mon, 01 Aug 2011 03:24:17 +0000

Thank you.

At the moment I'm using the Vinculum VDrive II. It works, but its serial interface is a slow as a wet week.

I'll wait for someone enterprising to come out with a hardware add-on that suits the Max32.

Frankly, I hope it isn't a "shield". That concept gets very old, very fast, as there are just too many pin conflicts for shields to be truly useful. My ideal solution would be a breakout board with connectors and a library that could be configured to use variable pin configurations.

Ron.


rtestardi

Mon, 01 Aug 2011 12:58:18 +0000

Is there a specific type of host you want to be? Are you trying to talk to a flash drive? Or a GPS? Or what?

Basically, as far as hardware goes, if you're talking hobby work (and you don't care about current limiting on VBUS, etc.), all you need is a USB connector on D+/D-...

-- Rich


TECH GEEK

Mon, 01 Aug 2011 13:12:51 +0000

just a general USB host for stuff.

needs to be in the mpide

also need a way to get TX, RX and RESET** signals that have the same data as the what comes out the FTDI chip.

basically i intend to program a BasicStamp2 from parallax.com using the my chipKIT without buying a USB to DB9 adaptor


whoover

Mon, 01 Aug 2011 14:16:15 +0000

There may be some useful code used for the Pinguino (website: pinguino . cc). The PIC32-Pinguino-OTG has an Arduino-like ported environment and uses a PIC32MX440F256H vs max32 PIC32MX795F512. So there may be some clues on how to get it working using a max32.

I'm also interested in getting a general use usb otg on a uno32 with some peripheral add-ons (seeing the PIC32MX320F128H doesn't support it :( ). I'm not sure how involved that would be (or if it's even worth the cost involved in doing so) :?:


rtestardi

Mon, 01 Aug 2011 14:53:35 +0000

basically i intend to program a BasicStamp2 from parallax.com using the my chipKIT without buying a USB to DB9 adaptor

So then you need an ftdi host... You won't find many of them in standard libraries, since it is a proprietary protocol that needs to be reverse engineered. I wrote my own ftdi device a while back (to simulate an ftdi chip -- the "other end" of what you want), and you can learn a lot about the upper level protocol driver you'll need to write yourself from it -- it's in the old StickOS skeleton projects (1.72 and earlier), here: http://www.cpustick.com/downloads/.


noisette

Wed, 24 Aug 2011 14:34:19 +0000

I've been using StickOS from Rich Testardi recently and the USB Host mode support works great!

But i need to have the same feature available within the ChipKit MAX 32 - Arduino compiler. Is this possible?

What i basically want to be able to do is to log my BMA180 accel values to a FAT32 file stored on a USB key connected to ChipKit MAX32.

Cheers, Jean-Francois


OppaErich

Wed, 24 Aug 2011 18:32:09 +0000

What's wrong with SDCards for this ?


rtestardi

Thu, 25 Aug 2011 18:26:22 +0000

I've been using StickOS from Rich Testardi recently and the USB Host mode support works great! But i need to have the same feature available within the ChipKit MAX 32 - Arduino compiler. Is this possible?

Microchip has a USB host driver as well, as part of their Microchip Application Library... My guess is that is the direction chipKIT will go for integration with MPIDE (that's the way I'd go if I were them :-))... There might be some issues related to the open source (or not) nature of that code that I don't understand, though.

If you want to use MPLAB X (rather than MPIDE), you can certainly recompile the StickOS skeleton project and get all those features, as well as C to code your application in (just removing the main BASIC program loop), but that's probably a lot of work...

What's wrong with SDCards for this ?

That's certainly another way to go, using the PIC32 SPI interface -- you obviously still need a block level driver and a filesystem on top of that -- is that available in Arduino library form for the chipKIT? Personally, I've found the USB Flash Drives to be a bit more convenient -- nothing is easier from a physical connection standpoint, and, of course, no card reader is required on the importing end.


swerwer

Fri, 11 Nov 2011 05:42:12 +0000

I am looking towards adding 3G and Wifi dongles. GSM dongles to be used in conjunction with remote management of wifi routers (via SMS), solar and battery status of equipment on remote towers. Pity that it seems that we would not be able to use the Uno32 as it seems from previous comments.


slayer1991

Wed, 11 Jan 2012 00:50:32 +0000

So can chipKit read/write on a USB flash drive instead of an SD card?


Jacob Christ

Wed, 11 Jan 2012 08:59:58 +0000

So can chipKit read/write on a USB flash drive instead of an SD card?

I haven't tested it, but there is a USB MSD Host Example Sketch.

Jacob


MGLSOFT

Wed, 11 Jan 2012 20:03:12 +0000

I do use that example, and write well in a pendrive, do not use it to read, but I assume that if it can burn, you can probably read it right ...


davervw

Fri, 20 Jan 2012 02:28:04 +0000

Where is the USB MSD Host Example Sketch?

AHHH [Edit] Nevermind, I see the new Network stack and USB post at the digilentinc site.