chipKIT® Development Platform

Inspired by Arduino™

UNO32 and sparkfun USB shield

Created Thu, 14 Nov 2013 13:35:53 +0000 by kaaasap


kaaasap

Thu, 14 Nov 2013 13:35:53 +0000

I am trying to get the sparkfun USB shield and UNO32 to work together.

Does anyone have the completed or even in process library for this?

I have downloaded the library for the shield, but I need to get it to work with UNO32.

Thank you.


Jacob Christ

Sun, 17 Nov 2013 17:17:32 +0000

It looks like this shield is based on the circuits@home board. My first chipKIT project was to port this library to the Uno32. I'll see if I can dig it up. I sent the files to Oleg to roll the changes into his library. My changes should have made the library work with both chipKIT and Arduino. If he didn't roll them in then you have lots of work. It took me about 40 hours to port the library, there is a lot of Atmel code and issues the variable type sizes between chipKIT and Arduino in there.

Jacob


Jacob Christ

Sun, 17 Nov 2013 18:51:55 +0000

I found it, I posted the code here:

https://github.com/JacobChrist/USB_Host_Shield

on a branch called chipKIT-dev

This code is 2.5 years old. I had it working with a circuits@home board and it was recognizing pretty much anything I plugged into the Max chip.

It looks like Oleg abandoned this repo and started a new 2.0 library a couple months after I made these changes. I think his plan was to switch to using standard types to make the libraries compatible across platforms but I don't know where he got.

Jacob


kaaasap

Thu, 21 Nov 2013 22:08:44 +0000

Awesome! Thank you very much.


Jacob Christ

Fri, 22 Nov 2013 04:55:49 +0000

Let me know if you get it going and/or if it needs updating.

Jacob


kaaasap

Wed, 04 Dec 2013 17:32:40 +0000

I have been trying to get it to work to no avail. I am now using the uC32 board as well and still not working...


Jacob Christ

Sun, 16 Feb 2014 03:18:28 +0000

Whats happening when you try to get it to work? Like I said I did this just as chipKIT came out and there maybe changes needed to get it to compile and or work with the latest compilers.

Jacob


kaaasap

Fri, 28 Feb 2014 19:24:56 +0000

To be completely honest I haven't touched it yet as I am working on other parts of my project. It is the next thing for me to work on. I think I will be moving away from the shield and use this https://www.sparkfun.com/products/11814 as it comes with the display. USB to UART and reduces package size.

I will keep you posted on it.


kaaasap

Wed, 12 Mar 2014 19:26:19 +0000

Yep, I will be using this https://www.sparkfun.com/products/11814

Has anyone tried using this as a USB port before?


kaaasap

Thu, 13 Mar 2014 12:10:39 +0000

figure I will be using chipkits "chipKIT Network and USB Libs-20130724" normally used on the chipkit shield


majenko

Thu, 13 Mar 2014 12:23:45 +0000

Yep, I will be using this https://www.sparkfun.com/products/11814 Has anyone tried using this as a USB port before?

How do you mean "as a USB port"? I use them for interfacing my computer's USB port to an RS232 device (like the 4D screens they're designed for), etc.

What are you trying to use one for?


kaaasap

Thu, 13 Mar 2014 12:36:47 +0000

I will be using it to read/write to thumb drives and to interface with keyboard/mouse.


kaaasap

Thu, 13 Mar 2014 12:43:19 +0000

I figure that the uC32 has the same FTDI chip to program it with using UART, why can't I use the smaller package of 4D's BOB for USB using software serial.

Please correct me if I am wrong. But since the network shield uses Microchips libs for USB control, and it doesn't use a MAX chip, I should be able to cobble something together that works. And why not? My project is bumping 21k lines of code anyways.


majenko

Thu, 13 Mar 2014 12:49:54 +0000

You can interface something like a PC, or other host USB device that knows about the FTDI chip, to a PIC32 based system through SoftwareSerial and one of those devices, yes. It's no different to using any other USB->TTL adapter.

The chipKIT USB library is for working with the internal USB peripheral built in to some of the PIC32 chips.


kaaasap

Thu, 13 Mar 2014 13:04:32 +0000

Unless there is a quicker and easier way I am going to explore this route.

As a starting point I opened the example "Generic USB" and hit compile just to see what would come up. At first glance, I need to define a few things, like U1PWRCbits, U1CONbits, U1CON, and U1IE.

Should be interesting...


majenko

Thu, 13 Mar 2014 13:30:19 +0000

If you don't have those defined, then the chip on your board doesn't support USB. You will need a better board.


majenko

Thu, 13 Mar 2014 13:36:20 +0000

How do you mean "as a USB port"? I use them for interfacing my computer's USB port to an RS232 device (like the 4D screens they're designed for), etc. What are you trying to use one for?

You cannot use that board like that.

The FTDI chip is a USB to serial convertor. It is a serial DEVICE, not a serial HOST. In order to connect an external USB device you have to have a HOST device to connect it to. The better PIC32 chips have one built in, which is what the chipKIT USB library uses.

You CANNOT communicate backwards through a device like you seem to think you can. USB is considerably more complex than basic serial.


kaaasap

Thu, 13 Mar 2014 13:40:50 +0000

okay, the start of that idea is dead.

I am now looking at using the SD library, modifing to run on softwareserial and not softwarespi, and changing SD to xxx. Would this at least allow writing files?

I would be using Microchips AN1045 definitions.


majenko

Thu, 13 Mar 2014 14:19:21 +0000

What exactly is it you are trying to communicate with? SPI and Serial are two completely different things and are not interchangeable.


kaaasap

Thu, 13 Mar 2014 14:27:52 +0000

I am attempting to use software serial to define a tx/rx pin to talk to the uart to usb converter. I will be modifying the SD library to use the pins set by software serial instead of spi.

If you have a better or easier way to use a uC32 board and write/read files to a USB thumb drive I promise I am all ears.


majenko

Thu, 13 Mar 2014 14:32:51 +0000

You cannot do what you think you can do.

You will require either a USB host shield, or a better board with USB peripheral built in, such as a MAX32, WF32, etc.

What you are trying to do, talk backwards through a USB to TTL device to another device, cannot be done. A host is required, which is what the better PIC32s are.

The only other way to do it, using the hardware you are thinking of using, is to plug the USB thumb drive into a PC, then plug the USB to TTL adapter into the same PC, and write some software to run on the PC to access the thumb drive and provide the files requested over a serial connection. All a bit pointless really ;)


kaaasap

Thu, 13 Mar 2014 14:50:52 +0000

Which host shields work with the uC32?


kaaasap

Thu, 13 Mar 2014 15:27:29 +0000

Majenko, can you elaborate on why the uC32 is not able to be used as a usb hub please.


mikes

Thu, 13 Mar 2014 16:02:53 +0000

I think your best solution is one of those SD cards that also have USB. The standard library should work for the SD side and you can use the USB side directly to a computer. http://www.overstock.com/Electronics/SanDisk-2GB-Class-4-Ultra-II-SD-Plus-USB-Memory-Card/5109895/product.html?gclid=CMa25KPwj70CFc1cfgodLkkA-A&cid=202290&kid=9553000357392&track=pspla&ef_id=UWWijwAABHnQizWd:20140313155800:s


majenko

Thu, 13 Mar 2014 17:36:33 +0000

Majenko, can you elaborate on why the uC32 is not able to be used as a usb hub please.

The MX3 chips simply do not have the USB on-the-go hardware. Only an external host chip can work, and I have no idea which ones have ChipKit software written for them. The WF32 would be your best board as it has a USB A socket there ready for you.


Jacob Christ

Sun, 16 Mar 2014 20:01:54 +0000

The PONTECH Quick 240 also has a USB A port that was added for this type of application.

Jacob


kaaasap

Wed, 07 May 2014 19:59:19 +0000

Almost done with the shield lib Jacob provided...

C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp: In static member function 'static void MAX3421E::regWr(byte, byte)': C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp:55:7: error: 'SPDR' was not declared in this scope C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp:56:16: error: expected ')' before ';' token C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp:56:16: error: expected ')' before ';' token C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp:56:30: error: 'SPIF' was not declared in this scope C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp:56:36: error: expected ';' before ')' token C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp:58:16: error: expected ')' before ';' token C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp:58:16: error: expected ')' before ';' token C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp:58:36: error: expected ';' before ')' token C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp: In member function 'char* MAX3421E::bytesWr(byte, byte, char*)': C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp:67:5: error: 'SPDR' was not declared in this scope C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp:69:16: error: expected ')' before ';' token C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp:69:16: error: expected ')' before ';' token C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp:69:30: error: 'SPIF' was not declared in this scope C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp:69:36: error: expected ';' before ')' token C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp:73:14: error: expected ')' before ';' token C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp:73:14: error: expected ')' before ';' token C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp:73:28: error: 'SPIF' was not declared in this scope C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp:73:34: error: expected ';' before ')' token C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp: In member function 'byte MAX3421E::regRd(byte)': C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp:93:5: error: 'SPDR' was not declared in this scope C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp:94:14: error: expected ')' before ';' token C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp:94:14: error: expected ')' before ';' token C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp:94:28: error: 'SPIF' was not declared in this scope C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp:94:34: error: expected ';' before ')' token C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp:96:14: error: expected ')' before ';' token C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp:96:14: error: expected ')' before ';' token C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp:96:34: error: expected ';' before ')' token C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp: In member function 'char* MAX3421E::bytesRd(byte, byte, char*)': C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp:105:5: error: 'SPDR' was not declared in this scope C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp:106:14: error: expected ')' before ';' token C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp:106:14: error: expected ')' before ';' token C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp:106:28: error: 'SPIF' was not declared in this scope C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp:106:34: error: expected ';' before ')' token C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp:110:16: error: expected ')' before ';' token C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp:110:16: error: expected ')' before ';' token C:\Users\melton\Desktop\mpide-0023-windows-20130715.\hardware\pic32\libraries\USBHostShieldmaster\Max3421e.cpp:110:36: error: expected ';' before ')' token


kaaasap

Wed, 07 May 2014 20:22:30 +0000

SPI is not recognized???

error: 'SPI' was not declared in this scope


Jacob Christ

Wed, 07 May 2014 20:24:08 +0000

Hmmm, it looks like its still picking up the Atmel Registers, did you pull the chipKIT branch? The master branch does not have the chipKIT code.

Jacob


kaaasap

Wed, 07 May 2014 20:30:20 +0000

Where would I find this branch you are talking about?


kaaasap

Wed, 07 May 2014 20:38:57 +0000

Besides having three instances of 'SPI' error, I have one instance of:

cpp:23:27: error: no 'void MAX3421E::init()' member function declared in class 'MAX3421E'

and that is all that is left!


Jacob Christ

Wed, 07 May 2014 21:08:19 +0000

When you clone the repo you get all the branches. Then you need to switch to the chipKIT branch.

There are lots of fine git tutorials on line. I might have time later today, in about two hours to do a google hangout.

Jacob


kaaasap

Fri, 09 May 2014 11:52:31 +0000

I tried the chipkit branch to no avail. To revisit the idea of using the FTDI FT232 BOB, I have found FTDI's driver for it and am considering porting it and trying it out. I have been able to talk to a computer as Majenko suggested could be done (quite easily). I know uC32 doesn't have USBOTG, but I have an example of a PIC33 (no USBOTG) talking to a thumb drive. No access to the code at the moment, working on that.