SAMD21, What the proper way to completely shutdown USB ?

1 post / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi

I like to shutdown DFLL48M and USB module to put to deep sleep since USB (in CDC and later MSC) is disconnected. The aim is to minimise current much as possible when MCU doing nothing (Sleep Mode). 

I also assigned PA03 to wakeup MCU when VBUS from USB is detected, how to correctly wake up the DFLL48M and USB module?, is there demo code that do that?

 

I found this snippet below, I guess I do this first to turn off USB and The MCU operates from OSC8M and then turn off DFLL48M clock and reverse for wakeup.

 

void udc_start(void)

{

       udd_enable();

}

 

/*! \brief Stop the USB Device stack

 */

void udc_stop(void)

{

       udd_disable();

       udc_reset();

}

 

I also found in Sleep Manager

 

 

I unsure if this really disables DFLL48M clock.

 

Any input would be appreciated, did you managed to turn off USB when disconnected (via VBUS monitoring) and turn on USB when connected without issue?