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:
And when I disconnect the USB to the PC I do the following routine:
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.
I'm not sure I fully understand the problem, is it this? :
- you power on the board- you connect it to PC via USB- you power off the board- you disconnect it from PC- you power on the board- you connect it to PC via USB and it doesn't work
Best regards, Milorad
I do the following sequence:
- I load my program on my board
- I connect the USB to my PC and it works
- I disconnect the USB to my PC and it works
(I can repeat the two last steps inifite times that they always work)
- I power off the board (with the USB disconnected, i.e. the disconnect functions have been done)
- I power on the board
- I try to connect the USB to my pC and it doesn''t works. The PC alert that it cann't recognized the USB device.
- I disconnect the USB and the alert dissapear.
(I can repeat the two last steps infinite times that the PC doesn't recognized the USB device)
On the other hand, I probed to debug this problem with uVision5, and something strange happened. I repeat the sequence that I have described, and if I am on the debugging mode, THE PC RECOGNIZE THE USB DEVICE AFTER A POWER OFF!! I am really desesperate with this because I see that all I am doing is right and logic.
Do u think that the problem may be a hardware problem? I don't think so, but I am starting to question me all.
Thanks for your answer Milorad.
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?
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.
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.
View all questions in Keil forum