Hello evreyone,
I have an issue with two interrupt.
An interrupt isttriggered each 5 second to wakeup my board.
LowPower.attachInterruptWakeup(RTC_ALARM_WAKEUP, triggeredAlarm, CHANGE);
The second is triggered when a drop falls into the rain gaude, and wakeup my board.
LowPower.attachInterruptWakeup(pin_arrosage, triggeredDropArrosage, RISING);
Over all, it's works fine, excepted that some time my code stop working. The loop stops.
I observedand I guess because I am not sure, the problem appear when the two intterrupt are triggeredat the same time.
Or, at a very close same time.
I haerd that two interrupt can not occur at the same time. The second is waiting until the first occur.
I also heard that an ISR must be short as possible.
I finaly heard the no Serial.print must occured in a interrupt
Now, I red that an ISR must complete its job within 6ms, or the second interrupt must occurs 6ms after the first.
So what is Ture, what is False??
Any Idea?
I am aware, that my ISR are too long, in any case because I add a Serial for debuging and I would like to have a led flashing when a interrupt occure.
Here is my bad code:
// Need to flash a LED and increment a value
void triggeredDropArrosage()
{
vcountDrops=vcountDrops+1;
//led_state = !led_state;
sw.digitalWrite(wakeup_led,HIGH);
delayMicroseconds(50000);
sw.digitalWrite(wakeup_led,LOW);
delayMicroseconds(50000);
sw.digitalWrite(wakeup_led,HIGH);
}
// Only need to flash a LED
void triggeredAlarm(){
sw.digitalWrite(wakeup_led,HIGH);
delayMicroseconds(50000);
sw.digitalWrite(wakeup_led,LOW);
delayMicroseconds(50000);
sw.digitalWrite(wakeup_led,HIGH);
delayMicroseconds(50000);
sw.digitalWrite(wakeup_led,LOW);
delayMicroseconds(50000);
sw.digitalWrite(wakeup_led,HIGH);
Si.sprintln(F("Alarm Wakeup now!"),1);
}
So, depending of what is False or True, how can I improve my two ISR to have a LED flashing and a Serial.print for debuging
Impoartant, as well, is there a way to make sure that triggeredDropArrosage() DO NOT occur , some ms before and after triggeredAlarm() is called?
How fast (in ms) an ISR must be completed?
many thank