- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I have a problem with my interrupts. First of them appears every 30 seconds (it's interrupt on timer), and the second appears when there is a "1" on one of the pins. The problem is that both of them triggers the same function, so I would like to have some kind of protection to be sure that when one of the interrupt already triggered this action, the other won't do that, because it's pointless and it causes troubles. How can I achieve that? I tried with :
if((flag_interruptclock == 1) && (flag_pir == 1)){
flag_conflict = 1;
}
for (i = 0; i < CMD_BUFF_LEN; i++) buffer = 0;
if ((flag_interruptclock == 1) || (flag_pir == 1))
{
if(flag_conflict == 0){
WIFI_SEND();
flag_interruptclock = 0;
flag_pir = 0;
}
}
but now it never triggers WIFI_SEND. I'm not sure what am I doing wrong. I'm attaching my whole project. Could anyone give me a hand?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
With 30 sec isr interval, the problem seems artificial. If isr2 occurred while isr1 is still running, you can ClearPending all interrupts at the end of isr code. But what if isr2 was fired, say, 100us after isr1 has completed? Some timing logic with "dead time" is necessary.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As @Odissey1 said above, the real solution to a software problem like this would be more software; You will need to add code to handle an "off-time" between triggers of the said interrupt function. That way, it will prevent both interrupts triggering the function within x amount of time of each other (Possibly 30s?)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok thanks for Your advices 🙂