I am writing an Interrupt service routine, and it exhibits 2 strange behaviours.
The routine is called every 100 mSecs, and takes 9 usecs to execute.
Whilst this routine is called, a value is checked if true a state is checked and changed.
If the condition is not true it is supposed to set the state to LOW.
What seems to happen is that when the value is true it enters that portion of the code, but then enters the section of code if the condition was not true.
But even more bizarre I have placed a Serial print in the false portion, if I program it to print a period "." it works, but if I program it print a numerical value the ISR completely hangs, I have also tried other functions and these cause it to hang as well.
It seems to be a compiler issue.
void set_timer(uint8_t iptr) // Immediate set of outputs
{
if (timers[iptr].period > 0) // timer is active turn on or flash
{
timers[iptr].pinstate=HIGH;
if(timers[iptr].flash == true) // flash enabled
{
if(timers[iptr].on_timer != 0)
{
timers[iptr].pinstate = HIGH;
}
else // state was low
{
timers[iptr].pinstate = LOW;
}
}
set_pin(iptr,timers[iptr].pin_no,timers[iptr].pinstate);
}
else // Force output off it has timed out
{
if (timers[iptr].invert == false)
{ digitalWrite(timers[iptr].pin_no,LOW); }
else {digitalWrite(timers[iptr].pin_no,HIGH); }
timers[iptr].pinstate=LOW;
// Serial.print(iptr);
}
}
The routine is called every 100 mSecs, and takes 9 usecs to execute.
Whilst this routine is called, a value is checked if true a state is checked and changed.
If the condition is not true it is supposed to set the state to LOW.
What seems to happen is that when the value is true it enters that portion of the code, but then enters the section of code if the condition was not true.
But even more bizarre I have placed a Serial print in the false portion, if I program it to print a period "." it works, but if I program it print a numerical value the ISR completely hangs, I have also tried other functions and these cause it to hang as well.
It seems to be a compiler issue.
void set_timer(uint8_t iptr) // Immediate set of outputs
{
if (timers[iptr].period > 0) // timer is active turn on or flash
{
timers[iptr].pinstate=HIGH;
if(timers[iptr].flash == true) // flash enabled
{
if(timers[iptr].on_timer != 0)
{
timers[iptr].pinstate = HIGH;
}
else // state was low
{
timers[iptr].pinstate = LOW;
}
}
set_pin(iptr,timers[iptr].pin_no,timers[iptr].pinstate);
}
else // Force output off it has timed out
{
if (timers[iptr].invert == false)
{ digitalWrite(timers[iptr].pin_no,LOW); }
else {digitalWrite(timers[iptr].pin_no,HIGH); }
timers[iptr].pinstate=LOW;
// Serial.print(iptr);
}
}