cancel
Showing results for 
Search instead for 
Did you mean: 

Problem receiving DATA after a SETUP in STM32F103 (USB FS Device)

hpipon957
Associate III

Hi All

Can anyone explain this?

I have a USB FS device driver which works as USB-MSD class but when I try to use the same driver for USB-CDC class it fails when the USB host sends a specific control transfer consisting of a SETUP token followed by a non-zero DATA packet. (Specifically when it is informing of the configuration and baud rate).

What I find is that (with a USB analser) the STM32F103's FS USB device is ACKing the DATA but it is not interrupting, nor saving the received data to the buffer. I can see in memory that the SETUP data is still in the buffer and the Rx count value is 0.

All other control transfers (which return DATA in response to a SETUP and then receive a ZERO DATA packet) operate as expected.

What could cause the USB FS device controller to accept the DATA but not store it or interrupt?

Note that if the receiver is not set back to the valid state (for some time) the controller NAKs the DATA, which is what is expected.

Finally note that when the host gives up on this control transfer and sends a following SETUP this is received normally.

Thanks

Mark

1 REPLY 1
hpipon957
Associate III

Update:

  • A bug has been found in the SETUP handling which was not setting the receiver state and RX toggle correctly. It was not noticeable until the DATA token immediately followed the SETUP and so still allowed USB-MSD to work(!!)
  • Confusing is the fact that if the RX is in the NAK state but the CTL flag is cleared the receiver still acks (but doesn't save the data), which makes analysis of the internal working from USB analyser recordings difficult because there is no obvious error on the bus.

I do however wonder - who on earth came up with the rx and tx state bit toggling idea because it makes coding a nightmare and requires more code that simply masking the fields?

Anyhow things are looking good again.

Regards

Mark