#17 interrupts Part-2: How most CPUs (e.g. MSP430) handle interrupts?

Поділитися
Вставка
  • Опубліковано 31 гру 2024

КОМЕНТАРІ • 54

  • @poulomiroy889
    @poulomiroy889 3 роки тому +4

    You are the GOD of the embedded world.I have been working for 12 years in embedded systems yet have never come across any tutorial like this.Thank you Miro, really grateful!!

  • @Freetoomy
    @Freetoomy 9 років тому +20

    Hi Miro,
    Firstly thank you so much for such a abstract tutorial on embedded systems programming. I have seen a lot of videos online and i have followed some pdf tutorials as well, but none have explained the way you have done. As a beginner in the embedded software world i see you as a first guide in my journey exploring embedded world. You have just cleared blockage in my mind that i had for pointer and dereferencing of the pointers.
    Miro, you being such a great tutor and expert in embedded systems, i feel you have to take this a step further in explaining complete modules and its interfaces with the ARM, like : SPI, UART, I2C, CAN, TCP/IP (Ethernet), RTOS and may be guide us to develop a real time system using these concepts.
    Please could you also make a video explaining "function pointers" in embedded systems perspective.
    Thanks and god bless your family !!
    (From the bottom of my heart)

  • @yasserel-azab7033
    @yasserel-azab7033 9 років тому +2

    Please don't suspend this amazing playlist, we're all excited to tackle more subjects.
    Thank you Sir :)

  • @ABDULSATTARM
    @ABDULSATTARM 9 років тому +2

    The interrupts lectures are more interesting, I am using interrupts at my work just as are; but today I really understood the concept of pre-emption and in-depth understanding what is going on at instructions levels. Thank you so much providing such in-depth knowledge.

  • @tomhijkl
    @tomhijkl 9 років тому +1

    Please make more videos, I enjoy them very much and they seem to be the easiest way for me to learn in my free time.
    Hope you read this.

  • @GLAProducer
    @GLAProducer 9 років тому +9

    Hi Miro, I'm a big fan of your video tutorials. Hope it will continue until RTOS.

  • @MohammedNoureldin
    @MohammedNoureldin 9 років тому +1

    Quantum Leaps, LLC , Hi, actually it is the fastest lesson!
    Your lessons are amazing! thanks a lot!

  • @zhitailiu3876
    @zhitailiu3876 5 років тому +6

    "One Thousand Golds for Every Word"

  • @kile9584
    @kile9584 6 років тому +1

    Thank you for the time you have dedicated to passing on you knowledge to us. I'd like to ask how do you tell the CPU to sleep?

    • @StateMachineCOM
      @StateMachineCOM  6 років тому +1

      Putting the CPU to sleep (via the WFI instruction) is demonstrated in lesson 25. Specifically, this 4th lesson on RTOS introduces the concept of the idle-thread, which is an ideal place to put the CPU to sleep and thus to save power. --MMS

  • @Natureguy71
    @Natureguy71 9 років тому +1

    Very good training. It helps me not only refresh many concepts but learn something new. Can you please also give some project/application ideas using ARM cortex? For example I want to practice writing my own device driver from the scratch. Also, if you can cover device drivers in the training that would be great. Thanks again & much appreciated.

  • @shamsunder1714
    @shamsunder1714 9 років тому +1

    Thanks for amazing tutorial series..It is really helpful...Will there be any additional tutorial? or it is end of the series?
    Thanks once again..

  • @mehdi52783
    @mehdi52783 6 років тому +2

    was the CPU frequency MCLK also divided by 8 ?? if not how it come that the timer register overflowed in just one CPU clock cycle (on the diagram 10:34) ??

    • @yanhairen8509
      @yanhairen8509 5 років тому

      Yeah, I have the same confusion, Do you know the answer now ?

  • @krish2nasa
    @krish2nasa 8 років тому +1

    Thank you very much Samek

  • @stansidorov
    @stansidorov 9 років тому

    Ewen though some ideas are quite obvious, I would like to thank you for your great videos. Good luck and carry on.

  • @charleshung157
    @charleshung157 8 років тому +1

    Hi, Dr. Miro Samek. I have finally reach this lesson 17.
    Thank you very much for the detailed lessons so far.
    Just like the other lesson, after finishing watching the lesson 17, I have a question I still don't understand.
    Here is my question :
    As you described in the video, the interrupt from MSP chip have a configuration with it's source clock being divide by 8. And the TA0R will only incremented at every 8 cycles. Using single step, you edited the TA0R value to 0xF422 (TA0CCR0=0xF423) to invoke the interrupt handler at will, exactly before the BIS instruction is executed. Then why, after the BIS instruction executed, the TA0R did actually incremented to 0xF423 ? Does the BIS instructions consume more than 8 cycles ? If not, then how could it incremented without waiting after the 8th cycles ?
    Hope you could enlighten me.
    Thank you. Warm regards.

    • @StateMachineCOM
      @StateMachineCOM  8 років тому +1

      When you stop your program at a random spot, the prescaler-counter inside the timer won't typically be zero. (The prescaler-counter counts from 0 to 7 and causes the TA0R register to increment once per overflow.) I am not quite sure what happens in the TimerA hardware when the stop the CPU at a breakpoint and you manually set the TA0R, but the prescaler apparently overflows on the very next count after you re-start the CPU. (It might be that the TimerA prescaler keeps running while the CPU waits at the breakpoint).

    • @charleshung157
      @charleshung157 8 років тому

      Thank you for sharing your assumption in how it may works.
      I'll try to dig deeper into it, if I have spare time.
      But, I have one more question which I forgot to ask before.
      I have read this :
      processors.wiki.ti.com/index.php/How_Do_Breakpoints_Work
      It's like TI wiki explaining about Hardware and software breakpoint.
      As far as I know, you haven't share your reason, why you used the hardware breakpoint, instead of the software one.
      May I know what is the reason ?
      Thank you. Warm regards.

    • @StateMachineCOM
      @StateMachineCOM  8 років тому +1

      The article you have referenced provides pretty good explanation of debuggers apply breakpoints. Perhaps I'll get to this issue in my future lessons.
      But regarding software breakpoints, they require changing the code, which is not easy in flash memory, where all the code lives in TivaC. (Flash requires an expensive block-erase cycle to change anything in it). In contrast, hardware breakponts work in any memory. I would not recommend using a microcontroller that does not support at least one, but preferably more hardware breakpoints.

    • @charleshung157
      @charleshung157 8 років тому +1

      Okay, I'll be waiting for more of your future lesson then.
      Thank you very much for your response, Dr. Miro.

  • @inanisneminem
    @inanisneminem 5 років тому +1

    Great lesson! So if an interrupt happens while another interrupt is ongoing, that interrupt will be fully ignored? Or will it start after the ongoing interrupt finishes?

    • @StateMachineCOM
      @StateMachineCOM  5 років тому +3

      An interrupt, even if happening while other interrupt is being serviced is typically NOT forgotten. Instead, the corresponding interrupt line is "latched", meaning that it continues to be in the "signaled" state until the interrupt is finally serviced. Then the ISR corresponding to that interrupt, when it eventually gets to run, explicitly "clears the interrupt source", meaning that it drives the interrupt line low (not signaled). This is necessary to prevent the interrupt from firing immediately again.
      Now, regarding of WHEN the interrupt is being serviced it depends on the "interrupt controller", which is the circuitry right before the CPU. Simpler CPUs, such as MSP430, can service only one interrupt at a time, so an interrupt simply waits until the previous one ends before it can be serviced.
      In more advanced CPUs, such as ARM Cortex-M, the interrupt controller is called NVIC and it has the capability of *prioritizing* interrupts. This means that an interrupt can *preempt* another interrupt when the new interrupt has a higher priority.

    • @inanisneminem
      @inanisneminem 5 років тому

      @@StateMachineCOM got it! Thank you so much Miro Samek and Quantum Leaps! You're godsent.

  • @bouazizihsan5777
    @bouazizihsan5777 4 роки тому

    hello,
    thank you so much for this fantastic tutorials. Can you explain please what is the advantages of calling C Function instead of interrupt Function?

  • @RebelKeithy
    @RebelKeithy 6 років тому

    Is it possible for the compiler to optimize out saving the extra registers during the function call in the interrupt if it knows that the extra registers don't need to be saved?

  • @yanhairen8509
    @yanhairen8509 5 років тому +1

    one confusion: when TA0R is set to F422, it takes 8 CPU clocks to increase to F423 and fire the interrupt for MSP430 LaunchPad (due to the clock divider). Thus seems the CPU should execute bic instruction first since it only consumes 1 CPU clock. Any explanation?

    • @StateMachineCOM
      @StateMachineCOM  5 років тому +1

      The number of clocks till firing depends on the internal state of the timer prescaler, which does not seem to be cleared when you set the TA0R register. Therefore the timer expires sooner than 8 CPU clocks. --MMS

  • @DarkOrje
    @DarkOrje 6 років тому

    I forgot to say, that I have a LaunchPad Tiva C Series, EK-TM4C123GXL with a TM4C123GH6PM chip.

  • @neharay9789
    @neharay9789 7 років тому

    Thank you for such a practical and beautifully explained discourse on interrupts..
    I have one doubt in the last section wherein the interrupt handler is calling a function. Why does the handler not save registers R0-R3 in addition to R12-R15? My understanding is that a function call can clobber R0-R3 , so why are these registers not saved?

    • @StateMachineCOM
      @StateMachineCOM  7 років тому

      According to the AAPCS (ARM Application Procedure Call Standard), the callee (the function) can clobber the registers R0-R3 and R12. In fact, R0-R3 are used to pass parameters into a function and R0 is used to pass the return value back to the caller. This means that the callee (the function) does NOT need to preserve these registers. That's the whole purpose and benefit of having a calling convention like the AAPCS. --MMS

    • @neharay9789
      @neharay9789 7 років тому

      Thank you very much for the clarification.
      Does AAPCS also apply to MSP430? The Arm-cortex M handlers preserve registers R0-R3 on interrupt entry.

    • @StateMachineCOM
      @StateMachineCOM  7 років тому

      As the name suggests A-ARM-PCS applies to ARM only. Compilers for other CPUs, like MSP430, also apply some procedure call conventions, but these might not be universal meaning that different compilers might use different conventions. With the ARM Cortex-M, the AAPCS is more universal, because it is actually implemented in the CPU itself. Specifically, the Cortex-M exception handling mechanism automatically preserves the registers clobbered by the functions in AAPCS. Please see lessons about interrupts in this video course. --MMS

    • @joserobins
      @joserobins 3 роки тому

      @@StateMachineCOM , Thank you Miro for this awesome video. One quick question. Assume that a caller function has just put values into R0-R3 (to pass parameters to the callee) and is *just about to* execute the BL instruction next to call the function in the Cortex-M4 when the interrupt happens. If the interrupt handler clobbers R0-R3, and when the *original* BL instruction is executed after the termination of the interrupt handler, the R0-R3 values are now invalid because the interrupt handler messed with it. How is that scenario prevented? Does the AAPCS require one to disable interrupts prior to passing parameters via R0-R3?

    • @StateMachineCOM
      @StateMachineCOM  3 роки тому +3

      @@joserobins This lesson-17 actually talks about interrupt handling in the MSP-430, while you apparently mean the ARM CPU. So, for ARM Cortex-M, the registers R0-R3,R12,LR,xPSR are saved automatically on the stack and then restored also automatically from the stack. Therefore, in ARM Cortex-M, the ISR can clobber all these preserved registers. Please watch the next lesson-18 about interrupt handling in ARM Cortex-M. --MMS

  • @yisong6665
    @yisong6665 6 років тому

    Question from the last point in this class. So if calling functions from an interrupt uses less memory than ISR, then we always want to call functions in interrupts? Is that correct or are there any other considerations? Please help! Thank you so much!

    • @StateMachineCOM
      @StateMachineCOM  6 років тому +1

      Calling a function is faster and uses less stack space than executing an interrupt/ISR. Calling a function from an ISR costs the same as calling the same function from any other context (e.g., from main()). --MMS

    • @yisong6665
      @yisong6665 6 років тому

      @@StateMachineCOM Thank you for your clarification!

  • @jasonwang7103
    @jasonwang7103 3 роки тому +1

    非常有用

  • @DarkOrje
    @DarkOrje 6 років тому +1

    Hi Miro,
    I get this error message in the build process.
    Error[Pe223]: function "__enable_interrupt" declared implicitly C:\embedded_programming\lesson17\main.c 16
    I use Your downloaded project lesson files.
    Your unzipped lesson is in "C:\embedded_programming\lesson17\".
    I have installed the "IAR Embedded Workbench IDE - Arm 8.30.1".
    My IAR installation is in "C:\assemble\IAR Systems\".
    I don't understand the problem. Can You/Somebody help me?

    • @DikshitThakuria
      @DikshitThakuria 4 роки тому +3

      try including the intrinsics.h header file
      #include

  • @catieadair97
    @catieadair97 9 років тому +1

    when's the next video coming?

  • @AgiriDeep
    @AgiriDeep 5 місяців тому +1

    How would this be done with the STM32?

    • @StateMachineCOM
      @StateMachineCOM  5 місяців тому +2

      This is precisely the subject of the *next* lesson "How interrupts work on ARM Cortex-M?". Please watch ua-cam.com/video/O0Z1D6p7J5A/v-deo.htmlsi=ILDEFJRX6C3S_qAx

    • @AgiriDeep
      @AgiriDeep 5 місяців тому +1

      @@StateMachineCOM Thank you

  • @mohamedhossamtealeb8682
    @mohamedhossamtealeb8682 5 років тому +1

    First, Thanks a lot for you DR. Miro samic
    Second, Do u know or anybody knows when i donwnload the lesson17 with the new header files and try to compile it....it give me error due to it cant open header files like core_cm4.h, cmsis_version.h and other header......But these header files are allocated in the standard library includes file in the IAR set-up file in the C driver.....and when i take copy and paste them in the lesson17 file location it works.....Does any one know why and the solution for it ??????????????
    Thanks

    • @StateMachineCOM
      @StateMachineCOM  5 років тому +2

      You need to additionally download the CMSIS.zip file and unzip it into the same directory, in which you keep the lessons for this course. The CMSIS stuff is available for download from the companion page to this course at: www.state-machine.com/quickstart/ . When you look there, every lesson that needs CMSIS offers a link to download the CMSIS.zip header file. This includes this lesson17. --MMS

  • @DarkOrje
    @DarkOrje 6 років тому

    That means, until lesson 16 (0x10), I could use Your (downloaded) project files, but not for lesson 17.

    • @StateMachineCOM
      @StateMachineCOM  6 років тому +1

      IAR version 8.x has apparently changed the system header file , which contains the prototype for the intrinsic function __enable_interrupt(). The fix is to explicitly include the header file at the top of main.c (#include ). All IAR projects for this video course (lessons 1-18) have been converted to the new IAR 8.x project structure and the line "#include " has been so that the projects build cleanly. Please download the zipped projects again from www.state-machine.com/quickstart/ . --MMS

  • @ABDULSATTARM
    @ABDULSATTARM 9 років тому

    Dear Miro Samek I have one request would you please remove the sub-heading/transcript from the video. Because of this sub heading I can not see in the video the register during debugging. Thanks.

    • @StateMachineCOM
      @StateMachineCOM  9 років тому +3

      Abdul Sattar
      To remove the captions just click on the "CC" icon in the navigation bar under the video.
      --MMS

    • @ABDULSATTARM
      @ABDULSATTARM 9 років тому

      Quantum Leaps, LLC Many thanks for your immediate response.
      Abdul Sattar

  • @boguwtuturicu5730
    @boguwtuturicu5730 9 років тому

    Hello Miro !
    Could use open source compiler : launchpad.net/gcc-arm-embedded and mecrisp-stellaris tool: github.com/zuloloxi/mecrisp-stellaris , an implementation of a standalone native code Forth ? Thanks !

  • @DarkOrje
    @DarkOrje 6 років тому

    Additional, I have to say, that Your project.ewp is converted.
    Sorry, for my messy question.