Interrupt WDT

gibson12345
Posts: 58
Joined: Wed Jul 17, 2019 11:45 pm

Re: Interrupt WDT

Postby gibson12345 » Wed Sep 11, 2019 4:37 am

Hey Sprite,
ESP_Sprite wrote:
Wed Sep 11, 2019 3:41 am
I think you're conflating two things here: one is wake-up, the other one is the interrupt. At the moment, it seems you have both set to level, that is, while the line is high, the CPU will keep waking up (which I think is what you want) and while the line is high, it will also keep triggering the interrupt. The second bit is what bites you: as the CPU keeps executing the interrupt handler over and over and over again, it does never have time to do other things and the watchdog will kill it.

Normally, the way you use a level interrupt is that in the interrupt routine, you clear the interrupt, in other words, you 'take away' the reason for the interrupt line to be high. In your case, it would mean e.g. resetting a chip that is connected to your GPIO line. In case you cannot do this, you're better served by an edge interrupt, which only triggers once when the signal goes high.

Note that this is different from using a GPIO as a wake-up source: the settings of that are, to my knowledge, not connected to the interrupt handling of a pin at all.
Okay I'm understanding a little more of the situation. I have the interrupt set on rising edge and wakeup set on high, so I should not get this repeated triggering of interrupts correct? This situation only occurs when the interrupt gets triggered while asleep not while the device is awake. As I mentioned in my original post (sorry if it wasn't written well) the interrupt only fires once when awake as it should and resets a timer to put the device into light sleep. When attempting to wake the device from sleep, it wakes correctly and calls the interrupt but it gets called continually thus triggering the watch dog. If I'm understanding what you've said correctly this should not be the case.

Let me know if I've stated anything that doesn't make sense.

Cheers,
Gibson

gibson12345
Posts: 58
Joined: Wed Jul 17, 2019 11:45 pm

Re: Interrupt WDT

Postby gibson12345 » Wed Sep 11, 2019 4:45 am

Hey WiFive,
WiFive wrote:
Wed Sep 11, 2019 4:31 am
Since the interrupt type is shared, if you configure the gpio interrupt as edge and then call

Code: Select all

gpio_wakeup_enable(LIS3DH_INTR, GPIO_INTR_HIGH_LEVEL);
the interrupt type is changed to level. When coming out of sleep, the gpio interrupt type is now level so it will repeat. You should probably disable the gpio interrupt before enabling the wakeup interrupt and then change it back to edge interrupt and reenable the gpio interrupt when coming out of light sleep.

https://github.com/espressif/esp-idf/bl ... pio.c#L103

https://github.com/espressif/esp-idf/bl ... pio.c#L480
Are you sure this is the case that the interrupt changes? That seems like it is counter intuitive. Shouldn't their implementation be seperate? (GPIO interrupt and Wakeup interrupt that is)

gibson12345
Posts: 58
Joined: Wed Jul 17, 2019 11:45 pm

Re: Interrupt WDT

Postby gibson12345 » Wed Sep 11, 2019 4:49 am

gibson12345 wrote:
Wed Sep 11, 2019 4:45 am
Hey WiFive,
WiFive wrote:
Wed Sep 11, 2019 4:31 am
Since the interrupt type is shared, if you configure the gpio interrupt as edge and then call

Code: Select all

gpio_wakeup_enable(LIS3DH_INTR, GPIO_INTR_HIGH_LEVEL);
the interrupt type is changed to level. When coming out of sleep, the gpio interrupt type is now level so it will repeat. You should probably disable the gpio interrupt before enabling the wakeup interrupt and then change it back to edge interrupt and reenable the gpio interrupt when coming out of light sleep.

https://github.com/espressif/esp-idf/bl ... pio.c#L103

https://github.com/espressif/esp-idf/bl ... pio.c#L480
Are you sure this is the case that the interrupt changes? That seems like it is counter intuitive won't I then not call the ISR that is triggered from that and then not be able to re enable the interrupt? Shouldn't their implementation be seperate? (GPIO interrupt and Wakeup interrupt that is)

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Interrupt WDT

Postby WiFive » Wed Sep 11, 2019 4:50 am

According to the code they are only separate if the gpio is a rtc gpio, otherwise shared

gibson12345
Posts: 58
Joined: Wed Jul 17, 2019 11:45 pm

Re: Interrupt WDT

Postby gibson12345 » Wed Sep 11, 2019 4:53 am

WiFive wrote:
Wed Sep 11, 2019 4:50 am
According to the code they are only separate if the gpio is a rtc gpio, otherwise shared
Yeah I see that now from the links you provided. But wouldn't disabling it then going to sleep mean that the ISR is attached to that interrupt never get called and therefor never able to set it back to edge?

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Interrupt WDT

Postby WiFive » Wed Sep 11, 2019 5:04 am

gibson12345 wrote:
Wed Sep 11, 2019 4:53 am
WiFive wrote:
Wed Sep 11, 2019 4:50 am
According to the code they are only separate if the gpio is a rtc gpio, otherwise shared
Yeah I see that now from the links you provided. But wouldn't disabling it then going to sleep mean that the ISR is attached to that interrupt never get called and therefor never able to set it back to edge?
Correct, I edited my post. If you rely on the interrupt firing coming out of light sleep, you can do it in the isr. Otherwise you can do it in the code that resumes from light sleep.

gibson12345
Posts: 58
Joined: Wed Jul 17, 2019 11:45 pm

Re: Interrupt WDT

Postby gibson12345 » Wed Sep 11, 2019 5:09 am

Hey WiFive,
WiFive wrote:
Wed Sep 11, 2019 5:04 am
gibson12345 wrote:
Wed Sep 11, 2019 4:53 am
WiFive wrote:
Wed Sep 11, 2019 4:50 am
According to the code they are only separate if the gpio is a rtc gpio, otherwise shared
Yeah I see that now from the links you provided. But wouldn't disabling it then going to sleep mean that the ISR is attached to that interrupt never get called and therefor never able to set it back to edge?
Correct, I edited my post. If you rely on the interrupt firing coming out of light sleep, you can do it in the isr. Otherwise you can do it in the code that resumes from light sleep.
That did it! Thanks a bunch for you help with this mess. How would you recommend that I change it back to edge directly from the ISR? using something like the below code?

Code: Select all

GPIO.pin[gpio_num].int_type = intr_type;
Cheers,
Gibson

Who is online

Users browsing this forum: Baidu [Spider], bnp117, EB Solution and 84 guests