• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

After interrupt PIR then Can I disable its after first to do interrupt process?.

Q&A Forum › Category: ESP32 › After interrupt PIR then Can I disable its after first to do interrupt process?.
0 Vote Up Vote Down
Apisit Mitpitak asked 4 years ago

After interrupt PIR then Can I disable the interrupt after first to do interrupt process?.

Question Tags: ESP32 with PIR Motion Sensor – Interrupts and Timers
1 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Hi!
If I understood well, you want to disable interrupt right after motion interrupt is triggered to execute a time critical task.
If that’s the case, you need to insert the following line out of the setup() and out of the loop()

portMUX_TYPE mux portMUX_INITIALIZER_UNLOCKED

Then, on the handling interrupt function, you need to add the following line right at the beginning:

portENTER_CRITICAL_ISR

then, at the end of the function, you need to add the following line:

portEXIT_CRITICAL_ISR(&mux);

Note: I haven’t tested this, but I’ve seen many examples that use this method.
It may be easier to understand if you take a look at the example code on the following tutorial:
https://techtutorialsx.com/2017/09/30/esp32-arduino-external-interrupts/
I hope this helps,
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] SMART HOME with RPi, ESP32, and ESP8266 (version 1.2) March 8, 2023
  • [eBook Updated] ESP32-CAM Projects (version 1.3) January 7, 2023

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2023 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.