0
\$\begingroup\$

I'm using an ATSAM4E16C microcontroller as a serial usb com port but it doesn't stay connected. After i plug it in i head the usb plugged in sound, and then it enters a loop where every 5 seconds or so it disconnects and reconnects immediatly.

I used this microcontroller on my own board and i was thinking if it could be because of a bad crystal oscillator. In the datasheed of the uC it said to use a crystal with a Load Capacitance between 12 and 18 but i used one with 10pF, and 15pF capacitors on each end. Could this be the issue, or should i look somewhere else?

Thanks

\$\endgroup\$
  • 2
    \$\begingroup\$ USB debugging is hard. You really need a protocol analyzer to understand what's happening during the attempted enumeration of your device. This can be either a hardware device like a Beagle 12 or an entirely software-based one. \$\endgroup\$ – Adam Lawrence Mar 17 '17 at 21:18
  • \$\begingroup\$ I would check connectors first. Bad contact or damaged USB connector might be the cause. \$\endgroup\$ – Anonymous Mar 17 '17 at 21:19
  • 4
    \$\begingroup\$ It might be totally unrelated. Every 5 seconds or so? Sounds like it might be the microcontroller's watchdog timer causing resets. Might be worth disabling the watchdag and seeing what happens... \$\endgroup\$ – bitsmack Mar 17 '17 at 22:18
  • \$\begingroup\$ It could be a device driver, that upon receiving wrong or NULL packet stalls the USB device. Make sure that OS device driver and USB stack running in MCU are the same application note. \$\endgroup\$ – Marko Buršič Mar 18 '17 at 0:15
  • \$\begingroup\$ @bitsmack, thanks for making me check the wdt again. That was the problem. \$\endgroup\$ – user3808318 Mar 18 '17 at 7:09
2
\$\begingroup\$

If your "own board" is not a PCB then all bets are off (if you prototyped this by hand). If it is a PCB then you need to find out where the problem is occurring in the system. Proablems like this could come from many things, so you need to verify that each piece of the system is working.

1) If you think its the clock, then run a timer test and see if it matches up with a reference clock.

2) It could be software. Remove your code and make a loop back test to and from your host, you could also see if the data lines of the USB are noisy.

3) You could also get some usb sniffing software that you run on the host and see if its your processor that is causing the usb to drop out or the hardware. Here is a reference on USB data flow.

\$\endgroup\$
1
\$\begingroup\$

thanks for the quick replies.

The problem was the WatchDog Timer causing the resets. This was my first idea as well but when i put in a loop wdt_reset() it kept doing the same. I think the problem was that i didn't actually initialize the wdt, it just used the default settings.

I had this exact same issue on another microcontroller, but i could disable this through the fuses, and since i didn't find any fuses related to the WDT on this microcontroller i thought it didn't need deactivation.

I thought that maybe capacitance mismatch between the uC and crystal would cause frequency drift that after 5seconds or so, would interrupt USB communication but i don't think it's that sensitive.

Thanks again

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.