I've been working on this for a couple of days. However I'm at a loss as to why my interrupt is not working.
Issue is the variable (PWMcount) that should be incremented in the ISR is not changing.
D2 and D3 are connected to an encoder (manual, contact type). My Logic analyzer shows the encoder working.
Can anyone post a functioning external pin interrupt sketch that is working?
Thanks
John
/*
This example shows how to wake up the SAMD21 from sleep with an external interrupt... NOT!
This sketch will break the USB during normal operation.
Double click the button contacts to enable bootloader mode for a new sketch.
The circuit:
- SEEED XIAO SAMD21.
*/
#include "Arduino.h"
#define ENCODERDATA D2 // aka PA10
#define ENCODERCLK D3 // aka PA11 and EXTINT[11]
uint16_t PWMcount = 100;
uint32_t startingMillis;
uint32_t now;
void setup()
{
Serial.begin(57600);
pinMode( ENCODERCLK, INPUT_PULLUP );
pinMode( ENCODERDATA, INPUT_PULLUP );
attachInterrupt( digitalPinToInterrupt( EXTERNAL_INT_11) , EIC_11_Handler, FALLING );
}
void loop()
{
// Simply prints out PWMcount every 5 seconds
now = millis();
if(startingMillis + 5000 < now){
Serial.print("PWMcount = ");
Serial.println(PWMcount);
startingMillis = millis();
}
}
void EIC_11_Handler(void) {
PWMcount = PWMcount + 1;
}