EIC Configuration Issue in SAME54 Unable to Call Interrupt Handler

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

Hello All,

 

I am using Xplained PRO Evaluation kit with ATSAME54P20A microcontroller and I am trying to generate interrupt using EIC controller but unable to do so currently. My configuration to generate interrupt is as follows:- 

 

void EIC_Init()
{
      MCLK->APBAMASK.reg = MCLK_APBAMASK_EIC;
      GCLK->PCHCTRL[4].reg = (GCLK_PCHCTRL_CHEN | GCLK_PCHCTRL_GEN(0));

      PORT->Group[3].PINCFG[0].bit.INEN = 1;
      PORT->Group[3].PINCFG[0].bit.PMUXEN = 1;
      PORT->Group[3].PMUX[0].bit.PMUXE = MUX_PD00A_EIC_EXTINT0;

      EIC->INTENSET.bit.EXTINT = EIC_INTENSET_EXTINT(0);

      EIC->CONFIG[0].reg |= EIC_CONFIG_SENSE0_BOTH | EIC_CONFIG_FILTEN0;
      EIC->CTRLA.reg |= EIC_CTRLA_ENABLE;
      while(EIC->SYNCBUSY.bit.ENABLE);

         NVIC_EnableIRQ(EIC_0_IRQn);
}

void EIC_0_Handler(void)
{

}

I am trying to get EIC working for pin PD00 but unable to do that. Why the code doesn't land into the interrupt handler function written above ?? Does my configuration done in the code above correct ?? Please do let me know. 

 

Regards.

 

 

This topic has a solution.
Last Edited: Thu. Mar 19, 2020 - 10:39 AM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
      MCLK->APBAMASK.reg = MCLK_APBAMASK_EIC;

Use |=  Your code now turns on EIC  (which is actually on by default) but also turns off all other bits including GCLK which you need.

 

     EIC->INTENSET.bit.EXTINT = EIC_INTENSET_EXTINT(0);

This will not set anything since the define is

#define EIC_INTENSET_EXTINT(value)  (EIC_INTENSET_EXTINT_Msk & ((value) << EIC_INTENSET_EXTINT_Pos))

Problems such as this should be easy enough to spot in the debugger, just single step and make sure the io registers are updated as you expect.

/Lars

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

Hi @Lajon,

 

That indeed solve the problem. The problem is with setting the interrupt enable flag value. In the line below :- 

 

 EIC->INTENSET.bit.EXTINT = EIC_INTENSET_EXTINT(value);

In the above line by setting the appropriate value for the interrupt indeed solve the problem. The code works by passing of right hex value in the "value" field above. 

 

Thanks for your help.