Go Down

Topic: What am i missing? (using Interrupt) (Read 1 time) previous topic - next topic

k4hvd

Hello.
So I have been struggling with some code.
I use MKRGSM1400 and a switch connected to pin 7.

This code works, and it count pulses.

But running it together with some GSM and RS485 stuff i doesnt work at all.

Am I missing something?


Code: [Select]



const byte interruptPin = 7;  //digitalPinToInterrupt
uint16_t mCounter = 0;

void setup() {


  countBegin();
  debugStart();
}

void loop() {

  debugPoll(String(mCounter));
}

void countBegin()
{
  pinMode(interruptPin, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(interruptPin), countISR, FALLING);
}

void countISR() { mCounter++; }



//
void debugStart() { SerialUSB.begin(9600); }
void debugPoll(String what) {
 if (SerialUSB) {
    static uint32_t eee = 0;
    const uint8_t interval = 2;
    if (millis() - eee >= interval*1000UL) { SerialUSB.print(" >"); Serial.print(String(what)); eee=millis(); }
  }

}

k4hvd

Aha, I think i found it.

Forgot about the MKRGPS (i2C) module.
Disabling that enabled the interrupt.

lavignema

You encountered the same thing I did. I began using the I2C port and discovered that I/O pin 7 was wired to the socket. I use the GPS shield and it gives you control over the power usage. I had already been using the pin for sleep/wake functions and discovered the dual assignment of functions after my sleep/wake stopped working.

Go Up