[TriEmbed] M0 interrupts

Alex Davis alexd at matrixwide.com
Thu Nov 9 11:41:58 CST 2017


I made a little progress by looking at this post: https://forum.arduino.cc/index.php?topic=420453.0 <https://forum.arduino.cc/index.php?topic=420453.0>

I first moved my external interrupt over to A0, which is EINT2, and doesn’t seem to be shared by anything important. Then I added the following to my code:

REG_EIC_INTENSET = EIC_INTENSET_EXTINT2;

before the attachInterrupt()

and

REG_EIC_INTENCLR = EIC_INTENCLR_EXTINT2;

in the handler on wake. This seems to get things working, but not consistently. Sometimes it will wake up via tapping the accelerometer (as I want), and sometimes it acts like it’s not going to sleep at all.

Oh btw I had to do the following before calling __WFI() to get sleep to work at all:

    //set System Control Register (SCR) sleep bit to deep sleep (do once so wfi (wait for intyerrupt)  in loop waits)
    //There are 2 sleep modes, idle and standby (deep) Sleep bit is SCR bit 2, 0 is idle, 1 is standby
    // SCB->SCR |= 0b00000100; //just a test to see how to code binary--this works
    SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;  // set to deep sleep (bit-1) by ORing with 100
     //SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk;   //set to idle (bit=0) by ANDing with the inverse of above--leaves all bita alone except sleep, which ANDs to 0
    //  SCB->SCR &= 0b11111011;  //another test
    //There are 3 idle modes, 0 (CPU),1 (CPU,AHB clock),2 (CPU,AHB,APB). Set this if using IDLE
     PM->SLEEP.reg |= PM_SLEEP_IDLE_APB;  //idle turn off CPU, AFB, APB //Advanced Peripheral Bus (APB)   Advanced High-performance Bus (AHB)

M0 support is definitely still beta. Too bad.

|\ |  (¯  \/ |¯\  |V| |\ ¯|¯ |¯) | \/ | | | |¯\ (¯   /¯  /\ |V|
|-||_ (_  /\ |_/ @| | |-| |  | \ | /\ |^| | |_/ (_ . \_  \/ | |







-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.triembed.org/pipermail/triembed_triembed.org/attachments/20171109/49e595c5/attachment.html>


More information about the TriEmbed mailing list