0

Feather M0 Adalogger interrupts
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Feather M0 Adalogger interrupts

by RipVW on Sat Feb 16, 2019 11:08 pm

Greetings,

I have an interrupt working by tying the data ready pin of an accelerometer to pin 6 of the Adalogger

Code: Select all | TOGGLE FULL SIZE
attachInterrupt(digitalPinToInterrupt(6), ISR_dataReady, HIGH);  // Enable interrupt


It works fine for HIGH and LOW, but not for RISING or FALLING. Is there a common mistake that causes that problem.

My main question is due to wanting to similarly attach a second accelerometer's data ready pin to the Adalogger. Looking at the pinout diagram I see pin 6 labeled as EINT4. Does the 4 indicate the interrupt priority? If I want the second accelerometer to have a slightly lower priority should I connect it to Adalogger pin A4 which is labeled EINT5?

BTW, I found this post to be very helpful:
https://forums.adafruit.com/viewtopic.php?f=57&t=96561&p=484827&hilit=interrupt+priority#p484827

Many thanks for your time,

RipVW
 
Posts: 3
Joined: Fri Jan 18, 2019 2:13 am

Re: Feather M0 Adalogger interrupts

by adafruit_support_carter on Mon Mar 04, 2019 12:35 pm

This is a fairly complex topic. In general, you are asking about using external interrupts on a Cortex M0, the ARM core processor used on the Feather M0. The numbers refer to the specific external interrupt source. Prioritization has various aspects. That thread you linked has some good general info. Other details would be found in datasheets and other reference manual on the Cortex M0.

adafruit_support_carter
 
Posts: 12587
Joined: Tue Nov 29, 2016 2:45 pm

Re: Feather M0 Adalogger interrupts

by adafruit_support_mike on Tue Mar 05, 2019 1:18 am

RipVW wrote:Looking at the pinout diagram I see pin 6 labeled as EINT4. Does the 4 indicate the interrupt priority?

No. It's just the ID number for that interrupt.

The SAMD21's external interrupt controller can handle 16 signals, identified EXTINT[0] through EXTINT[15]. All of the SAMD21's digital pins can connect to the EIC, but only to a single interrupt ID.. physical pin 25 can only connect to the EIC's EXTINT[0] circuit, for instance. There are more physical pins than EIC circuits, so physical pin 1 can also connect to EXTINT[0]. The pin multiplexer can only connect EXTINT[0] to one of those pins at any time, so part of configuring the chip involves setting up the interrupt connections.

The EIC only generates one interrupt in the ARM M0+ microcontroller, regardless of which physical pin felt the signal. At the microcontroller level, 'interrupt priority' only refers to which peripheral has priority over another.

RipVW wrote:If I want the second accelerometer to have a slightly lower priority should I connect it to Adalogger pin A4 which is labeled EINT5?

The Arduino environment's keeps an array of function pointers assigned as callbacks for external interrupts. When the microcontroller gets an EIC interrupt, it iterates the list from 0 to 15, checking the interrupt register to see if the EIC interrupt was caused by EXTINT[n], and if so, getting the corresponding callback pointer from the array and executing it.

That means a pin connected to EXTINT[4] would get checked just before a pin connected to EXTINT[5].

You could call that a slightly higher priority, but it would be very slight. Both pins would have to trip interrupts during the same CPU clock cycle for it to make a difference.

adafruit_support_mike
 
Posts: 58339
Joined: Thu Feb 11, 2010 2:51 pm

Re: Feather M0 Adalogger interrupts

by RipVW on Wed Mar 06, 2019 3:02 am

Hi Mike, Thank you for your time writing a detailed reply. Since Carter's reply I have spent 3+ hours reading the datasheet, and a bit more time searching forums. I was mostly understanding things as you described, but it is a huge help to have some confirmation and additional clarity.

Regarding the interrupt not triggering on RISING or FALLING, I found this in the datasheet on p368, 21.6.2.1
2. If edge detection or filtering is required, GCLK_EIC must be enabled
. I'm guessing that is not enabled and tried to find out where that is done. My best guess is on p130, Table 15.4, value 0x05. I suppose that is a bit in a register, but have no idea how to read or change that bit. Have seen a few ideas on accessing the registers but wasn't impressed with the chances of them succeeding. Do you have a method of doing that that you would recommend?

Thanks again for your time.

RipVW
 
Posts: 3
Joined: Fri Jan 18, 2019 2:13 am

Re: Feather M0 Adalogger interrupts

by adafruit_support_mike on Fri Mar 08, 2019 3:36 am

If you want a low-level view of what's happening, the code in the board support package does the necessary setup. The file you want is Winterrupts.c:

https://github.com/adafruit/ArduinoCore ... terrupts.c

adafruit_support_mike
 
Posts: 58339
Joined: Thu Feb 11, 2010 2:51 pm

Please be positive and constructive with your questions and comments.