Author Topic: Only get one Interrupt  (Read 76 times)

AKotowski

  • RFduino Newbie
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Only get one Interrupt
« on: August 04, 2017, 08:09:49 PM »
I trying to get an interrupt driven input routine to work.  The problem I am having is that I only get 1 (one) interrupt when I use attachPinInterrupt.  Until I use another attachPinInterrupt I get no more interrupts.  Am I doing something wrong?

Code: [Select]
volatile int intCount =0;
int intPin = 4;
bool interrupted = false;

void setup() {
  Serial.begin(9600);                 // Enable logging of the various events during application execution
  Serial.printf("Setup\n");
   intCount = 0;
   interrupted = false;   
   attachPinInterrupt(intPin, intRoutine, LOW);
//   dynamic_attachInterrupt(intPin, intRoutine, LOW);
//   interrupts();
}
void loop() {
  Serial.printf("Loop\n");
  Serial.printf("Count: %d\n", intCount);
  if (interrupted){
      Serial.printf("Interrupted\n");
  }
  delay(1000);   
//     attachPinInterrupt(intPin, intRoutine, LOW);     
}
int intRoutine(uint32_t dummyPin){
  intCount++;
  interrupted = true;
  return 0;
}


RFD_Nelson

  • RFduino Team
  • *****
  • Posts: 35
  • Karma: +0/-0
    • View Profile
Re: Only get one Interrupt
« Reply #1 on: August 07, 2017, 07:27:35 AM »
Hi AKotowski,

A couple of things I would ask you to test out:

Change interrupted to a volatile bool.
Make sure to use dynamic_attachInterrupt() instead of attachPinInterrupt().

Thanks,

Nelson

AKotowski

  • RFduino Newbie
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Only get one Interrupt
« Reply #2 on: August 07, 2017, 09:23:35 AM »
Nelson:

Thanks for you reply.

I get type conversion errors when I use  dynamic_attachInterrupt() .
However, I have made the code work!  I need to set the interrupt pin to input ( pinMode(intPin, INPUT); ).
I dont know how but it must have been set to output.

Bst Rgds

Andy

 

anything