AnsweredAssumed Answered


Question asked by Mike on Jun 9, 2015
I'm about at my wit's end with this problem. 

I am trying to get USB host mode to work on the F407 Discovery board. I am using CubeMX with the USB middleware code -- version 4.8.0. Keil IDE.

When I connect a keyboard, I get intermittent behavior, which usually involves a TXERR following the first call to USB_WritePacket during enumeration. This happens in less than 1 millisecond after the fifo data is written, so it's not a timeout. It only happens with keyboards. And it happens about 50% of the time when a keyboard is connected. I can connect other things (hub, flash memory etc) and it does not recognize them but it gracefully enumerates them and then gracefully closes them down. With keyboards, I get TXERR very often.

In addition to that, there is a lot of random behavior, sometimes just no response at all to the WritePacket, other times successful enumeration. Sometimes when plugging in a device, the HAL HCD_IRQ goes to the Port IRQ handler with PCDET set but PCSTS not set, which takes the state machine down the "disconnect" path, while other times it works fine. Sometimes the IRQ handler is entered twice with the exact same state -- PCDET set and PCSTS set.

I have seen all of these things happen from a reset state -- reset the board, plug in a keyboard, and it's totally random what happens after that. This makes no sense. If the system is behaving randomly from reset, there is either a race condition in the software, or there is a problem in the hardware.

I don't expect any detailed answers to these questions -- I've seen the same questions posted here quite a few times over the past year or two, but no solutions. My questions are these:

  1. Has anybody actually got host mode working with a keyboard with the code from CubeMX?
  3. Is there a fundamental problem in the CubeMX code? 
  5. Is there a fix if so?
  7. Is there something wrong with the F407 host mode hardware core?