chipKIT® Development Platform

Inspired by Arduino™

Attention all you USB junkies!

Created Sat, 08 Jul 2017 21:22:44 +0000 by majenko


majenko

Sat, 08 Jul 2017 21:22:44 +0000

Over the past couple of weeks I have been working on a new USB stack for chipKIT boards.

This is intended, eventually, to replace the USB support in the core, but for now whilst testing and enhancing it with more devices it is in the form of a standard library you can drop into your favourite IDE.

The new stack gives you easy access to a number of USB device mode profiles which you can mix and match at will:

  • USB Serial Port (CDC/ACM)
  • Keyboard
  • Mouse
  • Joystick
  • MIDI Interface
  • Raw HID

Not all the interfaces to these devices have been fully finalised yet.

As I mentioned you can mix and match them at will. In any combination, and with any quantities, up to the limit of the number of available USB endpoints (15). Note that the USB Serial Port uses 2 endpoints for each instance, but all the others use just one.

At the moment it only supports PIC32MX based boards, but my next task is to work on a PIC32MZ driver for it.

So feel free to have a play and break it. Report bugs back to me either here or on the Github issues page for the repository.

Download from: https://github.com/MajenkoLibraries/USB


GrahamM242

Tue, 11 Jul 2017 16:08:13 +0000

I'll have to take a look when I get some time!


GrahamM242

Tue, 11 Jul 2017 17:00:23 +0000

Ok, is it just me or transferring CDC data about twice as fast as it used to be?


majenko

Tue, 11 Jul 2017 17:33:26 +0000

I haven't done any speed tests yet. I'm just rejoicing that it's working...


majenko

Tue, 11 Jul 2017 17:36:54 +0000

Oh, and I have got MZ support working today.

***** YES, WE HAVE USB ON MZ NOW!!! *****


EmbeddedMan

Tue, 11 Jul 2017 19:54:25 +0000

Is CDC/ACM working in high speed?

*Brian


majenko

Tue, 11 Jul 2017 22:34:15 +0000

It's working in the mode called "high speed" - but is it working "in high speed"? No idea ;)

I need to dig out Paul's test sketch / client.


majenko

Wed, 12 Jul 2017 00:20:26 +0000

Looks like 5.5MBps. That's megaBytes, not megaBits...


GrahamM242

Wed, 12 Jul 2017 07:20:49 +0000

Nice work!

<OT Warning>That makes MZs look a lot more interesting. What boards/chips are currently supported?


majenko

Wed, 12 Jul 2017 09:12:20 +0000

All of them. ;)

One word of warning: that's not the real data throughput speed - that's the speed the computer can throw the data at the chip - the chip is most likely discarding most of it since it can't fit in the serial RX buffer and it's not reading fast enough.

I am about to see if I can set a larger buffer, give it a high-water mark trigger of 1 endpoint packet less than full, and "stall" the endpoint until there is room for at least 1 more full packet. That should give us a more realistic idea of t he real speed of communication. Maybe. If it works.


majenko

Wed, 12 Jul 2017 10:44:29 +0000

ok, high water mark implemented (I think). It's much slower now - a more realistic speed. Not fast, but then I've not written it to be fast (yet) - only to work which, given the lack of any documentation, is a small miracle ;)

Peak speed seems to be with 8 byte packets, which cause no stalling to occur. This yields about 600Kbytes per second. Less than that and the packets get too small to be efficient and the overheads are too great - it slows down. Larger than that and stalling starts to occur as the code can't read the buffer fast enough, and the speed drops.

So at the moment with inefficient code (copying data manually between FIFO and buffer, then between buffer and circular buffer), and reading with readBytes() it's on a par with a Teensy using read(). 6x faster than a Due, though, and a little faster than an MX using read().

Room for improvement, yes, but still not bad considering.


Jacob Christ

Sun, 08 Oct 2017 17:39:16 +0000

I'm totally rolling this into my chipKIT class this year!

Thanks Manjenko!

Jacob


majenko

Sun, 08 Oct 2017 21:04:46 +0000

Yay! I've been masculated!


EmbeddedMan

Mon, 09 Oct 2017 00:01:20 +0000

I've been using this new USB stack pretty much non-stop for a couple months now, and have zero problems with it as a CDC serial replacement.

I think one of our next steps for the chipKIT project is to roll this new stack into a v2.0 core release before the end of the year.

*Brian


majenko

Wed, 19 Sep 2018 09:30:11 +0000

Pretty high speed. As good as I've been able to squeeze out of it. The speed of the USB stack itself probably out-strips the ability of the Arduino API to handle the incoming data anyway with its primitive blocking ethos.