Hello,
I would appreciate if anyone could help.
I would like to achieve fast read speed for teensy 4.1 (either on change or better on rising edge). I found a solution with attachInterrupt that works, but I wanted to check with if there is a quicker way to read. My attempts to use ISR failed, because the board is an ARM board as I understood. I tried looking up for some other examples but was not able to found so far, if I miss it, please kindly direct me..
I would appreciate if anyone could help.
I would like to achieve fast read speed for teensy 4.1 (either on change or better on rising edge). I found a solution with attachInterrupt that works, but I wanted to check with if there is a quicker way to read. My attempts to use ISR failed, because the board is an ARM board as I understood. I tried looking up for some other examples but was not able to found so far, if I miss it, please kindly direct me..
Code:
IntervalTimer myTimer;
const byte interruptPin = 2; //button
volatile unsigned long blinkCount = 0; // use volatile for shared variables
unsigned long blinkCopy; // holds a copy of the blinkCount
void setup() {
Serial.begin(9600);
pinMode(interruptPin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(interruptPin), button, CHANGE);
}
void button() {
blinkCount = blinkCount + 1;
}
void loop() {
noInterrupts();
blinkCopy = blinkCount;
blinkCount = 0;
interrupts();
Serial.print("blinkCount = ");
Serial.println(blinkCopy);
delay(1000);
}