airpanther
Active member
Good day,
I have a function that I would like to run at regular intervals without disrupting the rest of the program. I'm using an IntervalTimer, which basically sets a series of pins high then low, which should then trigger the associated interrupts that generate a "1" or "0" on "falling."
When I run the code below from the "loop" function, I get 0111, which is exactly the output I want. But when I run it in an IntervalTimer, the output is simply 01. Basically, no matter how many times I set the pins high then low, I only get back "01". I've tried setting the priority, which doesn't seem to help. Does IntervalTimer cause interrupts to stop running?
Code excerpt:
const int binaryZeroPin = 9;
const int binaryOnePin = 10;
IntervalTimer iTimer1;
void setup()
{
iTimer1.begin(iTimer_tick, 10000);
}
void loop()
{
// Other stuff
}
void iTimer_tick()
{
// Trigger an interrupt that outputs a "0"
digitalWrite(binaryZeroPin, HIGH);
delayMicroseconds(15);
digitalWrite(binaryZeroPin, LOW);
// Trigger an interrupt that outputs a "1"
digitalWrite(binaryOnePin, HIGH);
delayMicroseconds(15);
digitalWrite(binaryOnePin, LOW);
// Trigger an interrupt that outputs a "1"
digitalWrite(binaryOnePin, HIGH);
delayMicroseconds(15);
digitalWrite(binaryOnePin, LOW);
// Trigger an interrupt that outputs a "1"
digitalWrite(binaryOnePin, HIGH);
delayMicroseconds(15);
digitalWrite(binaryOnePin, LOW);
}
Thanks so much for any input you can provide!
Robert
I have a function that I would like to run at regular intervals without disrupting the rest of the program. I'm using an IntervalTimer, which basically sets a series of pins high then low, which should then trigger the associated interrupts that generate a "1" or "0" on "falling."
When I run the code below from the "loop" function, I get 0111, which is exactly the output I want. But when I run it in an IntervalTimer, the output is simply 01. Basically, no matter how many times I set the pins high then low, I only get back "01". I've tried setting the priority, which doesn't seem to help. Does IntervalTimer cause interrupts to stop running?
Code excerpt:
const int binaryZeroPin = 9;
const int binaryOnePin = 10;
IntervalTimer iTimer1;
void setup()
{
iTimer1.begin(iTimer_tick, 10000);
}
void loop()
{
// Other stuff
}
void iTimer_tick()
{
// Trigger an interrupt that outputs a "0"
digitalWrite(binaryZeroPin, HIGH);
delayMicroseconds(15);
digitalWrite(binaryZeroPin, LOW);
// Trigger an interrupt that outputs a "1"
digitalWrite(binaryOnePin, HIGH);
delayMicroseconds(15);
digitalWrite(binaryOnePin, LOW);
// Trigger an interrupt that outputs a "1"
digitalWrite(binaryOnePin, HIGH);
delayMicroseconds(15);
digitalWrite(binaryOnePin, LOW);
// Trigger an interrupt that outputs a "1"
digitalWrite(binaryOnePin, HIGH);
delayMicroseconds(15);
digitalWrite(binaryOnePin, LOW);
}
Thanks so much for any input you can provide!
Robert