Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Using analog pin for interrupts? (Feather M4)
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: Using analog pin for interrupts? (Feather M4)

by vattiat on Thu Sep 26, 2019 5:12 pm

Martin,

Since last, I noticed that using pin 13 would get me correct measurements, while all other GPIO pins would return incorrect measurements. Since pin 13 has a resistor and LED connected to ground in the Feather board, I tried duplicating this arrangement on other pins using and external 2.2kOhm resistor and LED. And it worked.

So maybe give that a try? Set the interrupt pin to INPUT (not INPUT_PULLUP) and then put a ~2kOhm resistor and LED in series from your GPIO pin to ground.

vattiat
 
Posts: 2
Joined: Wed Sep 18, 2019 9:22 pm

Re: Using analog pin for interrupts? (Feather M4)

by baekgaard on Fri Aug 07, 2020 12:16 pm

I know this is a bit old topic, but I went through the same challenge and finally realised that the external interrupts in the variants.h file were wrong...

I can see that I was not the only one having this issue, as coincidentally another person "NanoCodeBug" also found this and fixed it a few weeks ago.

Anyway, if you have the issue, change ArduinoCore-samd/variants/feather_m4/variant.cpp as follows:

Code: Select all | TOGGLE FULL SIZE
  // 14..19 - Analog pins
  // --------------------
  { PORTA,  2, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel0, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 },
  { PORTA,  5, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel5, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_5 },
  { PORTB,  8, PIO_ANALOG, (PIN_ATTR_ANALOG|PIN_ATTR_PWM_E), ADC_Channel2, TC4_CH0, TC4_CH0, EXTERNAL_INT_8 },
  { PORTB,  9, PIO_ANALOG, (PIN_ATTR_ANALOG|PIN_ATTR_PWM_E), ADC_Channel3, TC4_CH1, TC4_CH1, EXTERNAL_INT_9 },
- { PORTA,  4, PIO_ANALOG, (PIN_ATTR_ANALOG|PIN_ATTR_PWM_E), ADC_Channel4, TC0_CH0, TC0_CH0, EXTERNAL_INT_6 },
- { PORTA,  6, PIO_ANALOG, (PIN_ATTR_ANALOG|PIN_ATTR_PWM_E), ADC_Channel6, TC1_CH0, TC1_CH0, EXTERNAL_INT_10 },
+ { PORTA,  4, PIO_ANALOG, (PIN_ATTR_ANALOG|PIN_ATTR_PWM_E), ADC_Channel4, TC0_CH0, TC0_CH0, EXTERNAL_INT_4 },
+ { PORTA,  6, PIO_ANALOG, (PIN_ATTR_ANALOG|PIN_ATTR_PWM_E), ADC_Channel6, TC1_CH0, TC1_CH0, EXTERNAL_INT_6 },

So analog pins A4 (PA04, feather pin 18) ) and A5 (PA06, feather pin 19) should be associated with external interrupts 4 and 6, respectively (and not 6 and 10).

Hope this helps others too :-)

baekgaard
 
Posts: 1
Joined: Thu Jul 30, 2020 7:22 am

Re: Using analog pin for interrupts? (Feather M4)

by Egholm on Sun Aug 09, 2020 7:07 am

Hi Per,

Thanks for the update...

Egholm
 
Posts: 10
Joined: Sun Sep 08, 2019 4:28 pm

Please be positive and constructive with your questions and comments.