I use the Freescale USB Stack v4.1.1 on a MK60FX512VLQ15 3N96B with a modified virtual com port example application.
Everything seems to work as expected, except for when an USB Set_Configuration(0) is followed by a Set_Configuration(1) request, after the application was already running correctly.
To catch the behaviour, I traced the USB ISR by letting a pin go high on entry and go low on exit of the ISR.
This is how it looks normally:
This is how it looks during the error condition (system not responding anymore at all):
It seems that the USB ISR is exited and immediately entered again. I somehow suspect that clearing the interrupt status flags does not work.
To catch where the problem begins, I added another pin going high when USB_Class_CDC_Event is entered, and low when it is exited again.
This is how the SetConfiguration(0) looks:
And this is how it looks after the following SetConfiguration(1). After exiting the event handler, the USB Interrupt problem as shown above begins, and the status phase of the setup transaction is never executed, all IN-transfers are NACK'd:
During the Uncofigure request, the endpoints are de-initialized in USB_Class_CDC_Event. During the following SetConfiguration request, the endpoints are reinitialized like in the initial SetConfiguration Request, which got the application running in the first place.
I have no idea how this setup transfer messes up things in the ISR.
Any help appreciated.