The source I use to toggle a LED on PortB 1.
Every thing OK except when I send a command from computer to toggle LED, the error has occurred every time after third or forth toggle.
Error => Could not find USB device "PowerSwitch" with vid=$16c0 and pid=$5dc!
Here is the source code that I suppose it was caused the problem.
Why I think so?
If I comment all lines that involve PORTB.It works fine.But,if I remove comments it doesn't work, and I got a problem mentioned above.
Code: Select all
else if(rq->bRequest == 1){ // use usbFunctionWrite to transfer len bytes to DDS
if(toggle){
PORTB |= 1 << BIT_LED; /* LED on */
}else{
PORTB &= ~(1 << BIT_LED); /* LED off */
}
toggle = ~toggle;
return 0;
}
Sorry for my English.