Hi Sabina,
I am sorry about the late reply.
I am using both K64F and K66F. Accidently, I mentioned as K64F, but I have the issue with K66F. Kindly accept my apologies.
Initially, I was trying to disconnect and connect K66F USB to PC completely through firmware. But, as I mentioned in the previous question, it got into an infinite loop.
So I thought of disconnect and connect it physically. The method was working perfectly fine even when the transfer is happening. But I need to use Memory Card when USB is disconnected. So I need to De init card for other use such as file access and then Init memory Card when I need to use memory Card for USB MSC Functionality. (Note: Since other functionalities such as I2S also reinitializing the Card, I need to DeInit the memory card)
So, below are the steps that I am following in the program.
1. Disconnect the USB cable physically and then press SW3 button to disable USB and memory Card.
2. Press SW3 to re-enable memory Card and USB
3. Physically connect USB to enable USB communication.
(When I develop a PCB for the final project, I am planning to have a switch to disconnect D+ and D- to replicate this condition.)
But the problem is that when I connect back USB cable (as mentioned in step 3 above), I get an error message as in the attached image. When I click the message to fix, it gets fixed and USB MSC functionality works fine. But, I feel the user will not be happy to see those kinds of messages in a product.
It would be of great help if I can fix this issue or a method for a graceful way of disabling USB MSC Functionality, use Memory Card for other purpose and reenable USB MSC Functionality even when the transfer is interrupted.
Thanks,
Mahendran
NB: I'll study, understand and use "USB_DeviceCancel" this week, thanks for the information.