Cannot Wake SAMD21 with EXTINT

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Before you ask, yes I have read  https://community.atmel.com/forum/samd21-samd21e16b-sporadically-locks-and-does-not-wake-standby-sleep-mode and still my problem persists.  I have spent several days working on this problem and haven't been able to get any closer to a solution.

 

I am developing on a SAMD21E17A on a custom board using a SEGGER EDU Mini.  I am using ASF libraries to execute most of the application, which can be challenging but have worked ok so far.

 

So I can get the micro to enter full STANDBY mode (measured less than 10uA) with a multimeter.  But the problem is trying to get it to wake.  

 

I have an external interrupt attached to one of the pins which is attached to external interrupt channel 10 which I configure as so.  I have also played around with NMI interrupt, no success there either.

    extint_chan_get_config_defaults(&wake_interrupt);
    wake_interrupt.detection_criteria = EXTINT_DETECT_HIGH;
    wake_interrupt.gpio_pin = PIN_PA10A_EIC_EXTINT10;
    wake_interrupt.gpio_pin_mux = PINMUX_PA10A_EIC_EXTINT10;
    wake_interrupt.gpio_pin_pull = EXTINT_PULL_NONE;
    wake_interrupt.wake_if_sleeping = true;

    //returnEic = _extint_get_eic_from_channel(WAKE_INTERRUPT_CHANNEL);

    extint_chan_set_config(WAKE_INTERRUPT_CHANNEL, &wake_interrupt);
	struct extint_events eventsList;
	for(uint8_t i = 0; i <= 31; i++){
	eventsList.generate_event_on_detect[i] = true;
	}
	extint_enable_events(&eventsList);

    extint_register_callback(wake_interrupt_callback,WAKE_INTERRUPT_CHANNEL,EXTINT_CALLBACK_TYPE_DETECT);
    extint_chan_enable_callback(WAKE_INTERRUPT_CHANNEL,EXTINT_CALLBACK_TYPE_DETECT);
	extint_chan_clear_detected(WAKE_INTERRUPT_CHANNEL);

I have validated that the interrupt works, because I can get it to trigger into my callback while the device is awake.

 

 

I am also running the RTC on GCLK 2 and I am swapping the main clock to the external 32k crystal as well before I go to sleep as so.

    struct system_gclk_gen_config mainClock;
    system_gclk_gen_get_config_defaults(&mainClock);
    mainClock.source_clock = GCLK_SOURCE_XOSC32K;
    mainClock.run_in_standby = true;
	mainClock.division_factor = 32;
    system_gclk_gen_set_config(0,&mainClock);

    system_clock_source_disable(SYSTEM_CLOCK_SOURCE_DFLL);
	SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk;
	sleepmgr_sleep(SLEEPMGR_STANDBY); 
	SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk;

    system_clock_source_enable(SYSTEM_CLOCK_SOURCE_DFLL);
    mainClock.source_clock = GCLK_SOURCE_DFLL48M;
    mainClock.division_factor = 1;
    system_gclk_gen_set_config(0,&mainClock);

 

 

I have also configured my clocks to run in standby (I know the main clock isn't required to run in standby to trigger the interrupt but I am trying exhaust all of my options)

/* Configure GCLK generator 0 (Main Clock) */
#  define CONF_CLOCK_GCLK_0_ENABLE                true
#  define CONF_CLOCK_GCLK_0_RUN_IN_STANDBY        true
#  define CONF_CLOCK_GCLK_0_CLOCK_SOURCE          SYSTEM_CLOCK_SOURCE_DFLL
#  define CONF_CLOCK_GCLK_0_PRESCALER             1
#  define CONF_CLOCK_GCLK_0_OUTPUT_ENABLE         false

/* Configure GCLK generator 2 (RTC) */
#  define CONF_CLOCK_GCLK_2_ENABLE                true
#  define CONF_CLOCK_GCLK_2_RUN_IN_STANDBY        true
#  define CONF_CLOCK_GCLK_2_CLOCK_SOURCE          SYSTEM_CLOCK_SOURCE_XOSC32K
#  define CONF_CLOCK_GCLK_2_PRESCALER             32
#  define CONF_CLOCK_GCLK_2_OUTPUT_ENABLE         false

 

I have also tried running the EXTINT on GCLK 0 and GCLK 2 (even though it shouldn't matter because I am triggering on HIGH and not filtering)

/**
 * Define which GCLK source is used when selecting EXTINT_CLK_GCLK type.
 */
#if (EXTINT_CLOCK_SELECTION == EXTINT_CLK_GCLK)
#  define EXTINT_CLOCK_SOURCE      GCLK_GENERATOR_0
#endif

 

And here is the weirdest thing.  When the device goes to sleep, the interrupt pin will not wake it.  But, if I set a breakpoint in the debugger, then trigger the interrupt, the device wakes...

 

Please help, my head is getting sore from collisions with my desk.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Bump

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Bump?