Hi all,
I am working with uVision5, Windows 10 and MK60FN1M0VMD12 (microcontroller)
I have implemented an USB as a virtual COM on my project and all work fine. When I load my program I am able to connect/disconnect the USB from my PC (host) and the communication is good in all the scenarios, but when I power off my board and I try to connect my USB again to the PC, I have a message that the PC doesn't recognized the USB port.
I have tried to update the drivers of the USB (done), and it doesn't work.
I have tried to manage the power management of the PC (done), and it doesn't work.
I have checked that the routine of connect/disconnect USB is working good. (When I power off the board, the USB is disconnected to the PC).
When I connect the USB to the PC I do the following routine:
USBD_Initialize((uint8_t) USB_DEVICE_ID); USBD_Connect((uint8_t) USB_DEVICE_ID);
And when I disconnect the USB to the PC I do the following routine:
USBD_Disconnect((uint8_t) USB_DEVICE_ID); USBD_Uninitialize((uint8_t) USB_DEVICE_ID);
All is good until I power off the board and try to connect again the USB to my PC.
The UART module works in all scenarios, so I suspect that I am forgetting something on the initialize/uninitialize routine.
Thanks all!
Hi javierrobledo,,
I think you have issues either with power of the board or the programming of the device.
When you say I load my program on my board, what does that mean, do you program it in flash or just use RAM for debugging?
Are you sure your program is running when you power-off and power-on the device?
Can you have one LED blink and see if the program is running on the board?
Best regards, Milorad
Hi Milorad,
When I say "load my program" I mean that I download my code on flash.
When I power off the board the program obviously stop, but when I power on the board again the program start to execute from the beginning (normal behaviour).
I dont have a LED, but I have a DC motor moving, I can communicate through UART... So yes, I know that my program is running after a power off.
Thank for your answer.
BR.
Hi javierrobledo,
I would suspect something with power from the USB once USB is plugged perhaps CPU resets and that would cause a problem.That seems why when you have debugger connected the debugger provides power also that reset does not happen.
Can you check if a rest happens when you plug-in the USB?
I think that I have solved the problem. I had two problems, one of them was the priority of my USB task. When I reset my board this task went to the final of the program stack and it never interrupts again. And the other was that when my program detected that there was no current going inside the circuit, it goes to a secure mode with ultra-low power consumption and (with the problem of the priority) the USB task was not able to wake up the system.
I was very desesperate because I was doing all right with logic, but this is a program of another developer, and understanding how someone thought is really difficult...
Thank you very much for your support Milorad. God bless you.
it seems that there is a lot more going on in your program then USB :-).
You are welcome.