[#3] ESP32 on Zephyr OS: GPIO Interrupt (ISR) [Part 3]

Поділитися
Вставка
  • Опубліковано 26 вер 2022
  • In this video, we'll update our ESP32 Zephyr application to toggle the LED state at the push of a button. There are several ways to achieve this goal, but our application will trigger an interrupt in Zephyr when we push the button down. The interrupt service routine (ISR) will toggle the LED state and return from the interrupt.
    This is the third video in the "ESP32 on Zephyr" series, so I recommend watching the previous videos first: • ESP32 on Zephyr OS
    Links:
    Zephyr Project button sample code: github.com/zephyrproject-rtos...
    Switch debouncing with RC network and Schmitt trigger: www.eejournal.com/article/ult...
    Switch debouncing with 555 IC: • The Best Possible Chea...
    ESP32-WROVER datasheet: www.espressif.com/sites/defau...
    GitHub discussion on GPIO inputs on ESP32: github.com/espressif/arduino-...
    Another GitHub discussion on the same topic: github.com/espressif/esp-idf/...
    ESP32 Errata: www.espressif.com/sites/defau...
    Pull request for including kernel.h: github.com/zephyrproject-rtos...
    GitHub repository for this video's code: github.com/bokfink/esp32_zeph...
  • Наука та технологія

КОМЕНТАРІ • 20

  • @GabeShaikh
    @GabeShaikh 11 місяців тому

    Great video! Thank you!
    A video discussing debouncing within the microcontroller using a timer would also be extremely helpful.

    • @thepullupresistor
      @thepullupresistor  9 місяців тому

      Thank you for the suggestion, I think that would be helpful to many. I will add it to my todo list :-)

  • @santoshkrishnanr3087
    @santoshkrishnanr3087 Рік тому

    thank you for your explanation. Good work . we need more .

    • @thepullupresistor
      @thepullupresistor  Рік тому

      Thank you for your comment! I will try my best to make more content that will hopefully be useful.

  • @chrisstjohn2234
    @chrisstjohn2234 Рік тому

    Interesting tutorial - thanks. It might be worthwhile making a video discussing switch bounce (what it is, perhaps with an oscilloscope trace) and how to overcome it in software rather than external hardware?

    • @thepullupresistor
      @thepullupresistor  Рік тому

      Thank you for the suggestion! I will definitely put that on the list of possible future video topics.

  • @zoeyzhang9866
    @zoeyzhang9866 Рік тому

    Nice tutorial! I really love your voice😆 Not sure if any custom PCBs you may need for upcoming content? If so, would be glad to sponsor and wish to having some collabs together! (PCBWay)

  • @mathicalee
    @mathicalee Рік тому

    Thanks for the video. I had some problems because I didn't have a debouncer (555 timer). After spending hours, I decided to buy some 555 timer. But looking at the datasheets, it seems to operate between 4.5V and 18V or even between 5V and 15V. But as far as I know esp32 has 3.3V. Does it work? (My background is mathematics and software developer, so I am quite new to hardware and electronic stuffs) Do you have a concrete model and manufacturer which does work for you? Thanks!

    • @thepullupresistor
      @thepullupresistor  Рік тому +2

      I'm sorry for the confusion I caused! Since the video is about GPIO interrupts in Zephyr, I tried to stay away from discussing debouncing (it is a big topic in itself).
      Based on the background you provided in your comment, I recommend the following approach:
      (1) The firmware should work without any debouncing circuit at all. Just connect the switch (button) to the microcontroller's pin directly. Depending on your switch, you may find that the LED responds well sometimes, and not well at other times. This is likely due to the "switch bounce" effect. But, at least you know that the interrupt is working (just not very well :-)).
      (2) Once you have set the circuit up and it is "working" as per (1), if you still want to explore debouncing the switch to make it more predictable, you can first try to implement a simple software debouncing routine in firmware. E.g. something like described in www.eejournal.com/article/ultimate-guide-to-switch-debounce-part-8/. I suspect that in industry these days, most debouncing is done in software, and things can get complicated quite fast. But since you mention you have a background in software development, this may be quite straight-forward for you.
      (3) If you still want to explore a hardware based debouncing circuit, then I suspect most 555 ICs will quite happily operate at 3.3V even though they are not rated as such in the datasheet. In my circuit, I used an NE555 from ST Electronics (www.st.com/en/clocks-and-timers/ne555.html) and it worked fine. Since you mention you are quite new to hardware and electronics, having a couple of 555 ICs around will be very helpful since they are incredibly versatile ICs and are used in many ways. Of course, I would not recommend using components in a way that is not covered in the operating range for any serious usage :-)
      A word of warning, however, I used an oscilloscope to choose appropriate values for the resistors and capacitor in my debouncing circuit. So you may need to do a lot of trial and error if you don't have a way to observe the edges. And if you don't have a collection of resistors and capacitors of different values lying around, you may need to get those, too, when experimenting. In short, a software debouncer may be much easier for you to implement without having to purchase new components. Then again, if you are interested in learning more about electronics, making a debouncing circuit may be a good excuse to invest in some components :-)
      I hope that helps, and sorry again for the confusion around debouncing circuits.

    • @mathicalee
      @mathicalee Рік тому

      @@thepullupresistor Thanks a lot!! 😆😆 Yes I already tried the software debouncer, but I had no clue what went wrong. But I will try again this weekend. And as you say, having some basic components makes sense.
      My first try was lua on esp8266. It was ok, but never stable. Then I learned C and used platformio and it was good enough for hobby programming. Now I want some more professional tool without gui or something, so I am learning zephyr. Nordic sdk is also based on zephyr, and I like nordic chips a lot. In the future, I want to do more for smart home, especially for matter and thread. My goal is to build some matter devices. So debouncing a button is definately what I need to learn 😁

    • @thepullupresistor
      @thepullupresistor  Рік тому

      Good luck and let me know how it goes! With your mindset of wanting to learn the underlying concepts, I'm sure you will get it working soon 🙂For me, the only way I really learn is to try, fail, try again, fail again, and finally (hopefully) find a solution. Don't give up and continue to reach out for help when you need to.
      After writing my previous reply, I realized that I should have mentioned one more thing to help you troubleshoot. The debouncing circuit inverts the signal, which is why we configured the GPIO pin to be GPIO_ACTIVE_HIGH in the devicetree overlay file in the video. When you remove the debouncing circuit, there are two things that need to change:
      (1) Change the devicetree overlay file to make the switch GPIO pin GPIO_ACTIVE_LOW instead of GPIO_ACTIVE_HIGH; and
      (2) Ensure that you have a pull-up resistor configured on the GPIO pin you are using for the switch input. This could be either a physical resistor connected to Vcc (3.3V) or add the GPIO_PULL_UP flag to the gpios property in the devicetree file.
      Something like:
      gpios = ;
      should work. Just replace 13 with the GPIO pin number you are using on your board. I hope that makes sense, but let me know if I can help to clarify further.
      Good luck with your troubleshooting!

    • @mathicalee
      @mathicalee Рік тому

      Thanks for your help. It works now after spending needless hours debugging. The main reason: the switch didn't work. I don't know since when. But the old debouncing code I tried before asked for help worked. But of course with your advice pulling up (had to understand what that is, and now I know) and changing the active low.
      But now it seems to make more sense. Thanks for your help. I'm having a lot of fun at the moment. And of course a lot of frustration. But I can handle it. I'm looking forward to more videos.

    • @thepullupresistor
      @thepullupresistor  Рік тому

      Great to hear that you got it working, and that you learned some new things (albeit with a bit of frustration). I'm sure you will find a lot of use for your understanding of debouncing in your future projects!
      I'm working on the next video at the moment, hopefully won't be too much longer :-)

  • @joachimwillner9904
    @joachimwillner9904 10 місяців тому

    Great Videos. We would like to start with zephyr on esp32s3. But we can't see if adc-driver is available. can we find info about that. br

    • @thepullupresistor
      @thepullupresistor  9 місяців тому

      Thank you. I hope you found a solution for your project. As I haven't tried the ESP32S3 yet I can't really comment on it. However, you should be able to use the ESP-IDF API's directly for functionality that has not yet been implemented for Zephyr. It's not ideal, of course, but at least an option.

  • @begoodbehappy-2691
    @begoodbehappy-2691 5 місяців тому

    can you please use teensy board to explain the project

    • @thepullupresistor
      @thepullupresistor  4 місяці тому

      Thank you for your suggestion. Unfortunately, I don't plan on getting a teensy board any time soon.

  • @ashwin372
    @ashwin372 5 місяців тому

    can you please make a a tutorial on vim setup that you have?

    • @thepullupresistor
      @thepullupresistor  4 місяці тому

      Thank you for your request. However, I use Emacs in these videos, not Vim (although I do use vi on some machines where Emacs is not installed). Sorry to disappoint ;-)