Windows could not recognize it after a reboot. It was recognizeed only after reconnecting.
I solved this problem by adding the following code:
Code: Select all
# include <avr/wdt.h> / / connect the library, watch dog timer
....
int main (void / / Start of program
{
......
wdt_enable (WDTO_8S); / / give the command to restart the controller through 8 s, if WDT not reseted
for (; ;) {/ * start the main program loop * /
if (usbConfiguration! = 0) wdt_reset (); / / reset wd_timer if device connected to the USB and recognized by OS
..........
}
}
That is, after starting the controller checks the value of usbConfiguration, if it is nonzero,
then the connection is successfully established and you can reset WDT.
If within 8 seconds, the device is not determined by the system, it goes to reboot.