• 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

8266 internal timer interrupt: not exiting despite timer.deinit()

Q&A Forum › 8266 internal timer interrupt: not exiting despite timer.deinit()
0 Vote Up Vote Down
Enzo Pontone asked 4 years ago

HI, please anyone could help me to understand why this sample code behaves this way:
it correctly waits 3 secs, prints “on_timer” and stays in the while loop (I checked this with a print inside it) because exit_flag is never set to 1 despite it’s global. Thanks for your help!

https://pastebin.com/az40hXN2

 

4 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Hi.

On line 6 you have:

exit_flag == 1

And it should be

exit_flag = 1

With only one “=”

Additionally, you are having a problem with global variable definition. Try this code, it will work as expected:

  • https://pastebin.com/UCZUP4nm

This discussion explains what was going on with your variable: https://forum.micropython.org/viewtopic.php?t=4814

I hope this solves your problem.

Regards,
Sara

0 Vote Up Vote Down
Enzo Pontone answered 4 years ago

Thanks Sara,
after some hours I’d better rest for a while: I rellay didn’t see the == 🙂
Regarding the global question: I see it works if I only declare the global in the callback (without the main declaration).
Can this lead to other problems?

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Hi again.
I’m not sure. I think it depends on your code.
Regards,
Sara

0 Vote Up Vote Down
Enzo Pontone answered 4 years ago

Ok, thanks!
Nice regards!

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

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

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

Copyright © 2013-2025 · 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.