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

  Рет қаралды 57,904

Quantum Leaps, LLC

Quantum Leaps, LLC

Күн бұрын

Пікірлер: 54
@poulomiroy889
@poulomiroy889 3 жыл бұрын
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 жыл бұрын
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)
@ABDULSATTARM
@ABDULSATTARM 9 жыл бұрын
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.
@yasserel-azab7033
@yasserel-azab7033 9 жыл бұрын
Please don't suspend this amazing playlist, we're all excited to tackle more subjects. Thank you Sir :)
@tomhijkl
@tomhijkl 9 жыл бұрын
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 жыл бұрын
Hi Miro, I'm a big fan of your video tutorials. Hope it will continue until RTOS.
@zhitailiu3876
@zhitailiu3876 4 жыл бұрын
"One Thousand Golds for Every Word"
@MohammedNoureldin
@MohammedNoureldin 9 жыл бұрын
Quantum Leaps, LLC , Hi, actually it is the fastest lesson! Your lessons are amazing! thanks a lot!
@Natureguy71
@Natureguy71 9 жыл бұрын
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.
@kile9584
@kile9584 5 жыл бұрын
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 5 жыл бұрын
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
@shamsunder1714
@shamsunder1714 9 жыл бұрын
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..
@charleshung157
@charleshung157 8 жыл бұрын
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 жыл бұрын
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 жыл бұрын
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 жыл бұрын
Okay, I'll be waiting for more of your future lesson then. Thank you very much for your response, Dr. Miro.
@krish2nasa
@krish2nasa 7 жыл бұрын
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.
@bouazizihsan5777
@bouazizihsan5777 3 жыл бұрын
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?
@inanisneminem
@inanisneminem 5 жыл бұрын
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 жыл бұрын
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.
@mehdi52783
@mehdi52783 6 жыл бұрын
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 ?
@yanhairen8509
@yanhairen8509 5 жыл бұрын
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 жыл бұрын
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
@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?
@neharay9789
@neharay9789 6 жыл бұрын
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 6 жыл бұрын
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 6 жыл бұрын
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 6 жыл бұрын
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 жыл бұрын
@@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
@DarkOrje
@DarkOrje 6 жыл бұрын
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 жыл бұрын
try including the intrinsics.h header file #include
@jasonwang7103
@jasonwang7103 3 жыл бұрын
非常有用
@yisong6665
@yisong6665 5 жыл бұрын
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 5 жыл бұрын
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 5 жыл бұрын
@@StateMachineCOM Thank you for your clarification!
@DarkOrje
@DarkOrje 6 жыл бұрын
I forgot to say, that I have a LaunchPad Tiva C Series, EK-TM4C123GXL with a TM4C123GH6PM chip.
@catieadair97
@catieadair97 9 жыл бұрын
when's the next video coming?
@AgiriDeep
@AgiriDeep 3 ай бұрын
How would this be done with the STM32?
@StateMachineCOM
@StateMachineCOM 3 ай бұрын
This is precisely the subject of the *next* lesson "How interrupts work on ARM Cortex-M?". Please watch kzbin.info/www/bejne/hWG9YndspZx9a6Msi=ILDEFJRX6C3S_qAx
@AgiriDeep
@AgiriDeep 3 ай бұрын
@@StateMachineCOM Thank you
@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 жыл бұрын
That means, until lesson 16 (0x10), I could use Your (downloaded) project files, but not for lesson 17.
@StateMachineCOM
@StateMachineCOM 6 жыл бұрын
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
@mohamedhossamtealeb8682
@mohamedhossamtealeb8682 5 жыл бұрын
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 жыл бұрын
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 жыл бұрын
Additional, I have to say, that Your project.ewp is converted. Sorry, for my messy question.
@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 жыл бұрын
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
#18 interrupts Part-3: How interrupts work on ARM Cortex-M?
15:27
Quantum Leaps, LLC
Рет қаралды 53 М.
#16 Interrupts Part-1: What are interrupts, and how they work
15:58
Quantum Leaps, LLC
Рет қаралды 79 М.
Un coup venu de l’espace 😂😂😂
00:19
Nicocapone
Рет қаралды 8 МЛН
My Daughter's Dumplings Are Filled With Coins #funny #cute #comedy
00:18
Funny daughter's daily life
Рет қаралды 23 МЛН
#20 Race Conditions: What are they and how to avoid them?
16:57
Quantum Leaps, LLC
Рет қаралды 41 М.
#9 Modules, Recursion, ARM Application Procedure Call Standard (AAPCS)
19:07
#3 Variables and Pointers
12:22
Quantum Leaps, LLC
Рет қаралды 183 М.
#1 How computers count?
17:06
Quantum Leaps, LLC
Рет қаралды 417 М.
#23 RTOS Part-2: Automating the context switch
37:37
Quantum Leaps, LLC
Рет қаралды 51 М.
#25 RTOS Part-4: Efficient blocking of threads
25:36
Quantum Leaps, LLC
Рет қаралды 26 М.
#6 Bit-wise operators in C
17:05
Quantum Leaps, LLC
Рет қаралды 123 М.
Un coup venu de l’espace 😂😂😂
00:19
Nicocapone
Рет қаралды 8 МЛН