SAMD21: 1uF cap on VDDCORE and 1k pull-up on SWCK required

Hi there!

I’m working on a SAMD21E16B product that will be rolled out in China, India and Africa in huge quantities. We use the STANDBY sleep mode (with RTC running) and under rare circumstances, the cpu locked up and would not wake up from an external interrupt. The only way to recover was to power cycle the micro, but then it lost it’s RTC time, which is game over for us. It turns out that there was a conflicting error in the datasheet (electrical checklist section) that Atmel has fixed in January (see attached PNG). This has bitten me BIG time and the sage advice applies: RTFM… if in doubt, RTFM again.

Make sure that you use a 1uF cap on VDDCORE (not 100nF), otherwise a voltage dip on the core supply can cause the cpu to lock up. Also make sure that you have a 1k pull-up on SWCK, otherwise an EMI event could look like a cold-plugging debug event to the cpu and it can also lock up.

This revision of the SAMD21 has a 100nF cap on VDDCORE:

https://cdn.sparkfun.com/datasheets/Dev … ut-v10.pdf

This revision of the SAMD21 has a 100nF cap on VDDCORE:

https://www.arduino.cc/en/uploads/Main/ … ematic.pdf

This revision of the SAMD21 has a 1uF cap on VDDCORE:

https://cdn-shop.adafruit.com/product-f … 7schem.pdf

But I don’t see a 1k pull-up on SWCK.

Regards,

Pieter

http://piconomic.co.za

Share and enjoy! (a reference to H2G2)

Thanks for the tip, Pieter.

Another question - are you using an external change interrupt to wake the rtczero standby (as opposed to level interrupt)?

If so, how do you set up the interrupt/sleep mode?

Any guidance would be greatly appreciated.

Hi Colin,

Sorry for the late reply (was away on holiday).

I have an external 32kHz crystal that I use to clock the external interrupt peripheral so that it is active even when the other clocks are stopped during STANDBY sleep mode. If you also use ASF, you must modify “conf_clocks.h” to enable the oscillator and keep it running in STANDBY mode:

/* SYSTEM_CLOCK_SOURCE_XOSC32K configuration - External 32KHz crystal/clock oscillator */

define CONF_CLOCK_XOSC32K_ENABLE true

define CONF_CLOCK_XOSC32K_EXTERNAL_CRYSTAL SYSTEM_CLOCK_EXTERNAL_CRYSTAL

define CONF_CLOCK_XOSC32K_STARTUP_TIME SYSTEM_XOSC32K_STARTUP_16384

define CONF_CLOCK_XOSC32K_AUTO_AMPLITUDE_CONTROL false

define CONF_CLOCK_XOSC32K_ENABLE_1KHZ_OUPUT false

define CONF_CLOCK_XOSC32K_ENABLE_32KHZ_OUTPUT true

define CONF_CLOCK_XOSC32K_ON_DEMAND false

define CONF_CLOCK_XOSC32K_RUN_IN_STANDBY true

You then need to enable a separate GCLK generator in “conf_clocks.h” and keep it running in STANDBY mode:

/* Configure GCLK generator 1 */

define CONF_CLOCK_GCLK_1_ENABLE true

define CONF_CLOCK_GCLK_1_RUN_IN_STANDBY true

define CONF_CLOCK_GCLK_1_CLOCK_SOURCE SYSTEM_CLOCK_SOURCE_XOSC32K

define CONF_CLOCK_GCLK_1_PRESCALER 1

define CONF_CLOCK_GCLK_1_OUTPUT_ENABLE false

In “conf_extint.h” you need to tell the peripheral to use GCLK1:

define EXTINT_CLOCK_SOURCE GCLK_GENERATOR_1

To put the CPU into STANDBY sleep mode, you can call the following function:

sleepmgr_sleep(SLEEPMGR_STANDBY);

I use an external edge interrupt to wake up the CPU, but I also tried an external level interrupt and got the same result: the CPU locked up and would not wake up. It could be worth your while to also read this thread:

http://community.atmel.com/comment/1953 … nt-1953791

In the end I decided to enable the watchdog (16 seconds reset) with the watchdog early warning interrupt (8 second interrupt) to wake up the CPU from STANDBY sleep mode and keep the watchdog happy. If the CPU does not wake up, then it will be reset 8 seconds later. This works well and the CPU is able to recover from the “deadlock”.

FYI, I found during my testing that the CPU locks up just by using the 8s watchdog early warning interrupt to wake it up (no external interrupt required). I used 4 test units: the first unit locked up within 1 day,… until all 4 units locked up after 4 days. So if you perform the test with 1 unit, it should lock up within 4 days.

NB! I have been unable to produce the problem on SAMD21 Xplained Pro boards (using SAMD21J18A), only on our boards using ATSAMD21E15B. The “B” device has a NVM area that can be used for non-volatile storage (instead of EEPROM). A fellow contractor has informed me that the NVM started to behave strangely after he enabled the early watchdog early warning interrupt, so he enables it only when going into STANDBY sleep mode (when he does not need to access the NVM area). I suspect that there is a link…

Anyway, good lock! If you find anything concrete, please post so that we can get to the bottom of it.

Best regards,

Pieter

Hi Pieter,

I’m travelling at the moment too, so I haven’t been able to try any of this out yet, but I really appreciate your detailed explanation. You’ve given me lots to think about. I’ll certainly let you know if it works out.

Regards,

Colin