Hello all,
I'm trying to add MSP430 support to the tinyusb USB stack, because it's what I'm used to and I figured a port wouldn't take too long.
The main functionality is working, but I've reached a snag where sometimes EP0 stalls without having set the STALL bit in USB{O,I}EPCNF_0, or traversing any of the STALL/clear STALL code whatsoever. Since I can't duplicate this behavior consistently, I believe there's a race condition somewhere, and I need to know under what conditions the USB Module will issue a stall on EP0. This is not mentioned anywhere in the Family Reference Manual.
Below is an example trace I captured of when a stall occurs on EP0 (data available upon request):
From experimenting, I've determined that I can force a STALL to occur by doing the following:
- Decode the Setup Packet.
- If the direction bit is set, clear the DIR bit in USBCTL, clear the NAK bit in USBOEPCNT_0, and set the NAK bit in USBIEPCNT_0.
- Upon receiving an IN packet from the host after all these conditions are met, the USB Module will issue a STALL to the host.
I'm not able to get an OUT xfer in the Status Phase to stall, even when I invert the directions in step 2.
My question is... are there other conditions that would cause the USB Module to STALL, or is this the only case? From staring at my code, I cannot currently find any code paths (even with interrupts) that would result in the above scenario, so my hope is that there are other combinations of cleared/set bits that can cause a stall when an IN packet is seen on EP0. Unfortunately this isn't documented in the manual, and I don't have access to a block diagram which could show me the STALL behavior.