USB host HID support

Go To Last Post
13 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I want to read a USB joystick using USB Host/OTG on an MCU.

 

The AT90USB647 looks ideal because it can be run at 5V which is useful to me, but the ASF does not have any USB support for it. I understand LUFA supports it, has anyone tested host functionality?

 

SAM DA1 is supported by Atmel Start. Unfortunately only HID mouse is listed under USB Host middleware, and while there is a generic USB host package the documentation is 404 (https://start.atmel.com/doc_driv...).

 

Other options include a PIC24FJ64GB002 with USB OTG, but Microchip's free XC16 compiler lacks optimizations and the maximum 16 MIPS it provides is borderline for what I'm doing. Maybe I could hand optimize in assembler. On the plus side it is 5V tolerant and there is some example code doing what I need.

 

Some STM32 parts look suitable and while the STM32 HAL stuff isn't well documented, the fact that there is any documentation at all puts it in the lead on that front.

 

External USB host ICs are an option but tend to be either large, expensive, difficult to hand solder or all three.

 

Any ideas?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

 

The LUFA Extension to Atmel Studio provides a USB Host Joystick Demo.

 

 

 

If you are not familiar with the LUFA Extension, see this post.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks, that is extremely helpful! I'll get a dev board and try it.

 

I also found the  PIC32MX2 series. While you still have to deal with the crippled free compiler, it does have DMA and 5V tolerant I/O. Quite cheap too.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm on PIC32 at the moment with a PIC24 project in the background.

 

Don't worry about the lack of optimisation on Microchip XC16 or XC32. It's gcc under the hood and you can use -O1 free-of-charge.

Don't worry about running out of flash; there's devices in the PIC24 range with 256K and more.

Don't worry about 16 MIPS. Being a 16-bit device, it is a wee bit more efficient than an 8-bitter.

 

The only thing I miss from AVR is the onboard EEPROM; but to be honest I don't see myself ever designing in AVR again. Having wrestled with pinout difficulties on AVR, the Peripheral Pin Select (PPS) feature is a real benefit. {Oops will that get me banned?}

 

PS: Having said that although I've not used the architecture; XMEGA does seem a step in the right direction.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I need a very fast response to interrupts. I think I'll have to do it in assembler. Basically a GPIO changes and I have 2us to update some other output GPIOs. The best option is usually to dedicate a port to the outputs so you don't have to read-AND-OR-write, you can just do a single write. 16 or 32 bit ports make that more difficult.

 

For one other thing I need to sample a 2MHz signal. On devices with DMA I can just use the DMA to keep reading the port into a RAM buffer, but on devices without DMA it will have to be an interrupt and code. 16 MIPS means 8 cycles per sample, and really you want two samples per bit... In assembler it might be possible to do a port read and store indirect with post increment, but I'd need to look at the PIC24 instructing timing. On AT90USB it is possible.

 

If only they made an XMEGA with USB host.

 

PIC32 with DMA seems like a good option, but I need to evaluate the software stack. LUFA is at least decently documented. I wish I knew about FPGAs.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

N.Winterbottom wrote:
{Oops will that get me banned?}
I raise you.

Exploring Microchip XC16 compiler | Details | Hackaday.io

by Jaromir Sukuba

01/09/2018

...

[second URL for PIC32 compilers]

...

In fact, I'm able to use optimizations higher than -O1 on free version. Compiler complains I have no valid license, but the code builds and runs just fine, with apparent results of compiler optimization efforts. 

...

[how to]

...

GitHub - cv007/XC3216: GCC compiler restrictions removal

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mojo-chan wrote:
... but I'd need to look at the PIC24 instructing timing.
PIC24 PMP has a synchronous mode in addition to an asynchronous mode.

PMP interfaces with displays and cameras (sync) and RAM (async)

mojo-chan wrote:
If only they made an XMEGA with USB host.
So close yet so far (lower right corner)

Core Independent Peripherals

mojo-chan wrote:
PIC32 with DMA seems like a good option, but I need to evaluate the software stack.
PJRC Teensy 3 has an alternative USB stack though it's on a competitors arm Cortex-M.

Teensyduino: Using USB Joystick with Teensy on the Arduino IDE

mojo-chan wrote:
I wish I knew about FPGAs.
FPGA can have a USB host controller though most seem to go via the USB controller in a MCU.

Can start with SystemC though will eventually learn Verilog or VHDL.

An alternative to arm in FPGA is RISC-V in FPGA; might not need much Verilog or VHDL to reach your goal.

DSP is the intermediate step to FPGA yet implement in C (and etc)

 

P.S.

Atmel's XMEGA and its XCL may have been a response to Cypress's PSoC.

A Cypress ARM9 with some programmable high-speed logic (GPIF™ II)) :

EZ-USB® FX3S™

due to

Turning the Cypress Super Speed Explorer Kit into a Continuous 200MS/s Logic Analyzer | Sysprogs

 


What is a Core Independent Peripheral? - Developer Help

Overview :: EZUSB communication core :: OpenCores (Cypress Semiconductor EZ-USB® interface to FPGA)

systemc / Repositories · GitHub (SystemC)

World's First RISC V based FPGA SoC Brings An Open Source Ecosystem With It - YouTube (2m48s)

via https://plus.google.com/+MicrochipTech/posts/VoPjwZyPJPK

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yikes! Those timing restrictions make things really difficult. That 2us GPIO update requirement rules out PIC24 at 16MHz where interrupt latency (10 cycles minimum I think) will kill it.

 

You'll most likely need a prioritised interrupt controller so that, for example, a low speed UART interrupt doesn't mess up your timing.

 

PIC32 loses out on latency due to an instruction cache but probably wins out by nature of the higher clock speeds available {Edit} and the shadow registers available on higher spec parts.

dsPIC33 may also be a worthy candidate.

 

Last Edited: Sun. Dec 9, 2018 - 04:03 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

gchapman wrote:
PJRC Teensy 3 has an alternative USB stack though it's on a competitors arm Cortex-M.

Teensyduino: Using USB Joystick with Teensy on the Arduino IDE

 

Sadly device only though. Starting to think about making a host capable USB stack... But don't really have the time.

 

Quote:
Can start with SystemC though will eventually learn Verilog or VHDL.

 

I feel like I need a really, really good book on the subject. I followed some university courses I found online, I think it was Verilog, and it didn't seem bad at all.

Last Edited: Sun. Dec 9, 2018 - 05:36 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

N.Winterbottom wrote:

Yikes! Those timing restrictions make things really difficult. That 2us GPIO update requirement rules out PIC24 at 16MHz where interrupt latency (10 cycles minimum I think) will kill it.

 

You'll most likely need a prioritised interrupt controller so that, for example, a low speed UART interrupt doesn't mess up your timing.

 

PIC32 loses out on latency due to an instruction cache but probably wins out by nature of the higher clock speeds available {Edit} and the shadow registers available on higher spec parts.

dsPIC33 may also be a worthy candidate.

 

Hmmm that's very interesting. I hadn't thought of the latency issue with PIC32. If the Parallel Master Port could be a slave port it would probably work. It's basically a demux, take one or two inputs and output one of 2 or 4 words.

 

It's very possible to do this on an XMEGA running at 32MHz. The architecture is great, interrupt latency is very low and with GPIOs and virtual ports you can make it this happen in under 1us!

 

The only other thing I can think of is an ARM running very fast, but none have USB host and 5V tolerant inputs. I could use level translation I guess.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mojo-chan wrote:
Starting to think about making a host capable USB stack... But don't really have the time.
Might jump-start given

Arduino - USBHost

GitHub - PaulStoffregen/USBHost_t36: Experiments with K66 USBHS Host Port

both due to

Using a teensy board to act as host for a USB device (not common devices!)

 


https://github.com/PaulStoffregen/USBHost_t36/blob/master/examples/Joystick/Joystick.ino

handled values of joystickType :

  • Sony PlayStation 3
  • Sony PlayStation 4
  • Microsoft Xbox 360
  • Microsoft Xbox One

PJRC Store, Teensy 3.6

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mojo-chan wrote:
If the Parallel Master Port could be a slave port it would probably work.
PMP slave modes :

Section 28. Parallel Master Port (PMP)

(page 12)

28.3 SLAVE PORT MODES

...

via dsPIC33EP256MU806 - 16-Bit - Microcontrollers and Digital Signal Controllers - Microcontrollers and Processors (70 MIPS, USB OTG)

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The NXP MCU used on the Teensy is €15!