How to enable NMI interrupt (D11/D10/D09)

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

Just posting some code to enable the NMI interrupt. It is presumed the EIC is being clocked.

 

PortGroup *const PortA = &(PORT_IOBUS->Group[0]);

voi NMI_enable()
{
    // setup NMICTRL
    EIC_NMICTRL_Type eic_nmictrl = {
        .bit.NMIFILTEN = 1,
        .bit.NMISENSE = EIC_NMICTRL_NMISENSE_FALL_Val,
    };
    EIC->NMICTRL.reg = eic_nmictrl.reg;

    // connect clock
    GCLK_CLKCTRL_Type clkctrl =
    {
        .bit.WRTLOCK = 0,   // lock
        .bit.CLKEN = 1,     // enable
        .bit.ID = EIC_GCLK_ID,       // clock
        .bit.GEN = 0,       // GCLK_GENERATOR_0  
    };
    GCLK->CLKCTRL.reg = clkctrl.reg;
    
    // NMI on pin 14 (PA_14) on D11/D10/D09
    PortA->PMUX[PIN_PA14 / 2].bit.PMUXE = MUX_PA14A_EIC_NMI;
    PortA->PINCFG[PIN_PA14].reg = PORT_PINCFG_PMUXEN;
}

void NMI_Handler()
{
    EIC->NMIFLAG.bit.NMI = 1;
    while(1) asm("nop");
}

 

Hope this avoids questions.

This topic has a solution.

Last Edited: Wed. Apr 20, 2016 - 02:46 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just a post to mark this as answered.