Introduction to RTOS Part 9 - Hardware Interrupts | Digi-Key Electronics

Поделиться
HTML-код
  • Опубликовано: 31 окт 2024

Комментарии • 32

  • @abhijanwasti7991
    @abhijanwasti7991 3 года назад +19

    I'm just started working with ESP32 at my new work and I cannot tell you how much this series has helped me! Thank you so much for making this available!

  • @mohamedhassanin6054
    @mohamedhassanin6054 3 года назад +17

    0:29 external interrupts
    1:40 what happens when an interrupt is fired
    2:37 demo
    8:45 binary semaphore
    12:06 Task notifications
    12:28 Challenge

  • @ksawery6568
    @ksawery6568 3 года назад +14

    Thank you for another great tutorial, however, I found the explanation of critical sections confusing and needed to do more research. I feel like the subjects of ISR critical sections, mutexes and spinlocks should be separated here. In my understanding, ISR critical sections are used to disable all interrupts for a very short period of time, to prevent race conditions between tasks and ISRs. Even though we may be in an ISR in one core, a task running on another core could still access the same variable; so we should protect it further with a mutex or spinlock. Mutexes and spinlocks can be used interchangeably, however, spinlocks are used here by default to prevent wasted CPU cycles. As opposed to spinlocks, mutexes put tasks to sleep, and that uses many CPU cycles. This isn't recommended if we access variables often and for short periods of time, as is the case in ISRs, therefore spinlocks are the obvious choice in ISR critical sections. Please correct me if I'm wrong.

    • @shadowtuber1589
      @shadowtuber1589 2 года назад +1

      Actually, spin locks are the opposite! The spin through cycles which uses more cpu cycles, while a mutex will block and therefore not use cpu. The reson why we use spin locks is because the "cost" of a spinlock is lower if we are not waiting too long, which should be the case with an IRS critical section. If however we may need to wait a while for the resource, then spinlocks, or "busy waiting" are wasteful and a mutex is preferred

  • @MrKoval-nm9ky
    @MrKoval-nm9ky 3 года назад +2

    I like this series, sometimes my code works but there is a better way to implement the same

  • @balachandarjeyalatha868
    @balachandarjeyalatha868 19 дней назад

    Hi hymel thanks for making a lecture🎉,make a video on clock ,based on that tick how a timer works in mcu

  • @blisca
    @blisca 3 года назад +2

    Hi,thank you for your effort to face it from the point of view of beginners, as i am.
    Question:about at 10:20 you perform an ADC conversion inside an ISR,in contrast with the rule of keeping every ISR very short.
    Was it done just for easyness of explanation?Thanks.

  • @MingOnUTube
    @MingOnUTube 2 года назад

    About the semaphore and the overrun flag in the challenge answer:
    Looks like the state is either (semaphoreTake TRUE + overrun = 0) OR (FALSE + 1),
    -> with (TRUE + 1) and (FALSE + 0) being unreachable.
    So, is the whole point of the overrun flag a signaling mechanism so that the error message "Error: Buffer overrun. Samples have been dropped." can be printed out?
    Suppose if we don't care about error message,
    -> buf_overrun is not needed in the ISR condition check "if ((idx < BUF_LEN) && (buf_overrun == 0))"
    -> if we use "if (idx >= BUF_LEN && xSemaphoreTakeFromISR(sem_done_reading, &task_woken) == pdTRUE)" to guard the whole buffer full section,
    -> so idx is not reset to 0
    -> "if (idx < BUF_LEN)" always fails until semaphoreTake is successful
    Did I understand it correctly?

  • @TomSky00
    @TomSky00 4 дня назад

    What happens when we call portyieldfromisr when there is no other task with higher priority that becomes unblocked after we have given the semaphore?
    I'm guessing it will call forth the schedular but that wont do anything because the other task is not ready yet and we just added 1 or 2 ticks lag to the normal process, is this correct? and is this the only downside of calling portyieldfromisr, if so why is this not routine behaviour?

  • @KaiseruSoze
    @KaiseruSoze 3 года назад +2

    Nice challenge problem. Image the look on their faces when they find out the template for a ring buffer isn't in the STL.

    • @ShawnHymel
      @ShawnHymel 3 года назад +2

      Hehe...yup, this was a challenging one :) I figured that at this point, I’ve talked about almost all of the “tools” in FreeRTOS to make something like a multithreaded sample-and-process program. The ring or double buffer parts are missing, but I figured that there are enough examples out there on how to use/make them (and they’re not really RTOS related, anyway) :)

    • @sigusr
      @sigusr 3 года назад +1

      Is there any reason not to use xQueueSendToBackFromISR(..) instead of a custom double buffer?

    • @ShawnHymel
      @ShawnHymel 3 года назад +2

      @@sigusr For this particular example, you can probably get away with using a queue, as data is being produced and consumed relatively slowly. However, queues are slow compared to direct memory read/writes, as they have extra overhead to be thread-safe. The point of the exercise is to create an RTOS application where you need to work with data being captured from a sensor at a rapid pace (and therefore would not be able to use a queue).
      If you're curious, this person found that queues can be written to or read from at about 3 us per access on the ESP32: techtutorialsx.com/2017/09/16/esp32-arduino-freertos-queues-performance-test/

  • @steliossideris6498
    @steliossideris6498 19 дней назад

    at the esp-idf we have general porpose timr and high resolution timer.what dιd
    you used?

  • @TomSky00
    @TomSky00 4 дня назад

    I wonder, what is the benefit of removing the setup task after execution? it seems pointless as the setup task only gets called once after booting anyway, doesn't it automaticly get removed?

  • @Dodek_Mardana
    @Dodek_Mardana Год назад

    Thank you for the knowledge shared, but I have an issue. I've tried several codes, but none of them seem to work. I don't understand how to use it on STM32F4. I'm using a hardware timer from TIM1, but it's not functioning. Can someone help me with how to code on STM32 using Arduino IDE?

  • @zaidansari9069
    @zaidansari9069 Год назад

    thanks shawn

  • @gacherumburu9958
    @gacherumburu9958 3 года назад +1

    Thanks for the info..👍

  • @SmokinLoken
    @SmokinLoken 10 месяцев назад

    I'm getting an error when I try to run this on my ESP32-S2-WROOM. The error I get is "abort() was called at PC 0x40027db7 on core 0" and then the ESP32 reboots and it just keeps repeating this. This makes me believe there is some sort of overflow happening (maybe with the timer_divider?). When I comment out the timerAttachInterrupt() line of code, I don't get the error. Anybody have anything they'd recommend I try?

  • @mimo2202
    @mimo2202 2 года назад

    I got error with the solution simple: Average: 124Guru Meditation Error: Core 1 panic'ed (Unhandled debug exception). any hint?

  • @fernandoi8958
    @fernandoi8958 2 года назад +6

    Jesus Christ this was too fast to understand it all lol

  • @abhinavabhi4525
    @abhinavabhi4525 3 года назад +1

    In esp32 which core will execute ISR functions? Is it possible to shift the ISR to a particular Core

    • @ShawnHymel
      @ShawnHymel 3 года назад +1

      The core in which the ISR was assigned (attached) will be the core that executes the ISR. It is not possible to move the ISR once attached to a core. This section gives more information about ISR: docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/intr_alloc.html#internal-peripheral-interrupts

    • @abhinavabhi4525
      @abhinavabhi4525 3 года назад +1

      @@ShawnHymel Thanks

  • @MuhammadDaudkhanTV100
    @MuhammadDaudkhanTV100 3 года назад

    Great

  • @louiscelenza8017
    @louiscelenza8017 2 года назад +5

    This should be titled Timer Interrupts not Hardware Interrupts.

  • @صبريعلي-ت7ل
    @صبريعلي-ت7ل 2 года назад

    see you again

  • @eddw123
    @eddw123 2 года назад +1

    I hate to be a slow listener 🤣, my old C++ professor was talking faster than this guy…C++ is an easy code but talking x2 speed , they try to give the illusions that is hard to learn it🤣.. so talking and explaining fast won’t make look smarter