Hello,
I'm working on a project which includes a Teensy 3.2 and another device. The other device sends 400 times per second high voltage ('1') to the Teensy 3.2 and for each interrupt of a high voltage(rising) this happens:
i++;
serial.println(i);
The thing is, if the rate is 200times per second, it sends one number each time (video number 1). If the rate is 400times per second, it sends the whole 400 numbers each time (which is not good for me) (video number 2).
1.Anyone knows how can I fix it?
2.Is this the fastest method I can use for interrupts?
The code:
define input 1
int i = 0;
void setup()
{
pinMode(input, INPUT);
attachInterrupt(input, srService, RISING);
}
void loop()
{
}
void isrService()
{
cli();
Serial.println(i);
i++;
sei();
}
Video 1: https://vimeo.com/638341671
Video 2: https://vimeo.com/638341686?from=outro-local
Thanks!
I'm working on a project which includes a Teensy 3.2 and another device. The other device sends 400 times per second high voltage ('1') to the Teensy 3.2 and for each interrupt of a high voltage(rising) this happens:
i++;
serial.println(i);
The thing is, if the rate is 200times per second, it sends one number each time (video number 1). If the rate is 400times per second, it sends the whole 400 numbers each time (which is not good for me) (video number 2).
1.Anyone knows how can I fix it?
2.Is this the fastest method I can use for interrupts?
The code:
define input 1
int i = 0;
void setup()
{
pinMode(input, INPUT);
attachInterrupt(input, srService, RISING);
}
void loop()
{
}
void isrService()
{
cli();
Serial.println(i);
i++;
sei();
}
Video 1: https://vimeo.com/638341671
Video 2: https://vimeo.com/638341686?from=outro-local
Thanks!