HAL: #2 How to - GPIO Interrupt

  Рет қаралды 62,590

Web learning

Web learning

6 жыл бұрын

In this video, I will show how to use the HAL EXTI Interrupt function.
Before you watch this, please see the video on how to use the STM32CubeMX if you dont already know how to use it.
• #1 STM32CubeMX Tutoria...
UM1724 - STM32 Nucleo-64 board: www.st.com/content/ccc/resourc...
*** 2 Free Board giveaway has ended ***. Make sure you subscribe and have the notification button on so you will know when you will get a chance to win also a board next time.
See this link for rules and restrictions: • Video
/ weblearning

Пікірлер: 60
@b0rd3mz
@b0rd3mz 5 жыл бұрын
before this, I was just a nobody who couldn't even interrupt my mother. Now, I know all the ins and outs of HAL programming. I even stood up to my mother yesterday. Thanks a lot man
@Weblearning1
@Weblearning1 5 жыл бұрын
Hahaha. A good one. Thanks.
@franciscomarcelo632
@franciscomarcelo632 6 жыл бұрын
Thx for the video!
@bharathip9012
@bharathip9012 4 жыл бұрын
Very useful Sir
@trt969
@trt969 6 жыл бұрын
Thanks!
@epicmap
@epicmap 5 жыл бұрын
Your mom: //walks into your room Her input: 1:31 user manual for *NUCLEAR BOMB* Your mom: //an *interruption* is triggered
@Weblearning1
@Weblearning1 5 жыл бұрын
I said Nucleo, but it can be heard like Nuclear..
@JeN-iy8rq
@JeN-iy8rq 6 жыл бұрын
Very nice 😍😍😍
@sudheerkumar5966
@sudheerkumar5966 2 жыл бұрын
Very good
@SonalK
@SonalK Жыл бұрын
ty
@tugbars4690
@tugbars4690 5 жыл бұрын
good explanation
@Weblearning1
@Weblearning1 5 жыл бұрын
Thanks.
@Arturikc
@Arturikc 3 жыл бұрын
Thanks a lot. kod works.
@Weblearning1
@Weblearning1 3 жыл бұрын
You're welcome! Dont forget to Subscribe and click the notification bell...
@Arturikc
@Arturikc 3 жыл бұрын
@@Weblearning1 ok
@ltlt6117
@ltlt6117 Ай бұрын
Hi how much is the time between interrupt(falling or rising edge) and function in normal case and how we can decrease this time ? (Doing the function immediately after interrupt without any delay)
@naasikhendricks1501
@naasikhendricks1501 6 жыл бұрын
yip was waiting
@Weblearning1
@Weblearning1 6 жыл бұрын
+Naasik Hendricks Hi. You are one of the free boards winner. Please send me your full address in a privet message.
@naasikhendricks1501
@naasikhendricks1501 6 жыл бұрын
Hi, First Thanks, super excited to get this board to dev and play with. Needless to say i will be following your tutorials to learn more. It is the first time, I have private message a content creator. The private msg is under about?
@GammaSigma1234
@GammaSigma1234 4 жыл бұрын
Thank you for this tutorial. However, I am still confused by the use of the "HAL_GPIO_EXTI_Callback" function. I'm still a learner: to toggle the LED, I would have written the "HAL_GPIO_Toggle" function in the stm32f3xx_it.c file, inside the "void TIM2_IRQHandler(void)" function. I didn't even know it could be done with the "HAL_GPIO_EXTI_Callback" function, in the main.c file. Do you also have a tutorial covering what a "callback" function is? Thank you in advance.
@Weblearning1
@Weblearning1 4 жыл бұрын
There are different ways to do things. in a nut shell, when writing code, its important to keep the code to a min. inside the interrupt. Its better to turn on a flag and then run the corresponding code outside of the interrupt. When generating code from the cubeMX, if you didn't set it to " Generate peripheral .c.h files" then you have to keep all your code in the main.c file.
@GammaSigma1234
@GammaSigma1234 4 жыл бұрын
Thank you very much for your help, that was really appreciated!
@aaakkk180
@aaakkk180 5 жыл бұрын
I tried with SET and RESET than the led blinks very well but why it is not working with interupt
@Weblearning1
@Weblearning1 5 жыл бұрын
Follow the complete video on the interrupt and make sure you did everything correctly.
@WBrianez90
@WBrianez90 4 жыл бұрын
why you does not use the it.c instead of callback? i'm trying on l451 nucleo board but into the USER CODE BEGIN/END 4 it's not works
@Weblearning1
@Weblearning1 4 жыл бұрын
Both ways are correct. Some use the it.c to write all their code, some use everything in the main.
@casholsen5848
@casholsen5848 6 жыл бұрын
This is a trap for young players! You should never use an interrupt with an unconditioned mechanical push button, sure it works in simulation but you'll be pulling your hair out debugging the real circuit. There is one exception, when you have a properly designed hardware debounce circuit, but that requires additional components and a more expensive spdt switch.
@Weblearning1
@Weblearning1 6 жыл бұрын
+Cash Olsen You are right, but this example is not just for a push button, it can also work for any device that you want to know a change, and with these you done need a denounce. These videos are examples of what you can do, and they are only the basic. If I had to cover all.options, each video would take over 45 min like the cumemx video.
@casholsen5848
@casholsen5848 6 жыл бұрын
Web Learning, I also agree with your position, but I think that way to many will try ideas just as they are published. This leads to poor designs, bad code, and unreliable products. At least, say that this approach has limitations and should not be used in certain circumstances. Unfortunately, the Arduino effect has re-introduced many of these poor practices back into code so that it must be thoroughly vetted rather than used without concern.
@Weblearning1
@Weblearning1 6 жыл бұрын
+Cash Olsen I totally agree with you and I see this on a daily basis. But this is the reason why I say in the begining of my video ..." Where knowledge is shared". There are so many perspectives for each thing I show and I hope to have more people like you to contribute with their knowledge on how to do things the right way. I will take your suggestion and i will try to be more clear in the examples that I will show. But yet again, I cannot cover everything.
@WaspLife
@WaspLife 6 жыл бұрын
Also it should be noted that this is for a Nucleo board, which has the B1 button debounced already ;)
@gabrieldornelles9310
@gabrieldornelles9310 5 жыл бұрын
you can actually fix it by coding, put a variable in the interruption that changes it state between 0 and 1, then when the while is executing, put the function HAL_Delay(something like 100 ms) and everytime you press the button, the program will wait 100ms before go to the interrupt again( because it only enters to make what you want in the interruption) if a flag(ex: _Bool flag=0) is 1, and it only turns 1 after 100ms and becomes zero and the end of while.
@varigondasaikrishna4102
@varigondasaikrishna4102 3 жыл бұрын
how its comes to this HAL_GPIO_EXTI_Callback function when pressing button?
@Weblearning1
@Weblearning1 3 жыл бұрын
Its part of the Interrupt handler that is looking for this function.
@aaakkk180
@aaakkk180 5 жыл бұрын
void HAL_GPIO_EXTI_callback(uint16_t GPIO_Pin) { if(GPIO_Pin == B1_Pin) { HAL_GPIO_TogglePin(LD4_GPIO_Port, LD4_Pin); } else{ __NOP(); } } SIR I ADDED THE ABOVE CODE IN MY main.c on my stm32l152rc discovery board but my led at PB6 does not turn on when i press b1 at PA0 can you tell me why. I choose EXTI line0 interrupt in NVIC
@Weblearning1
@Weblearning1 5 жыл бұрын
Without going to deep and for debug, change the toggle to SET to amke sure the led does work and you are not having any bouncing issues.
@NeuroMod
@NeuroMod 4 жыл бұрын
Isn't the nop() unnecesary? Also I believe the falling edge thing is more related to the signal than how B1 is connected, B1 should have a falling and a rising edge.
@Weblearning1
@Weblearning1 4 жыл бұрын
Only with the nop() you can put a brake point if you need one.
@aaakkk180
@aaakkk180 5 жыл бұрын
void HAL_GPIO_EXTI_callback(uint16_t GPIO_Pin) { if(GPIO_Pin == B1_Pin) { HAL_GPIO_Set_Pin(LD4_GPIO_Port, LD4_Pin); } else{ __NOP(); } } Is the above code is ok for turning on an led by pressin the button
@YashSharma-cq3zp
@YashSharma-cq3zp 5 жыл бұрын
your led must not be ld4 and do make it falling edge in gpio settings
@aaakkk180
@aaakkk180 5 жыл бұрын
what is the HAL STATEMENT TO TURN ON AN LED
@dtl19
@dtl19 6 жыл бұрын
Is the else-block just for style?
@Weblearning1
@Weblearning1 6 жыл бұрын
+Daniel Lond Yes. It's good to keep things in order when you explain them...
@Weblearning1
@Weblearning1 6 жыл бұрын
+Daniel Lond Hi. You are one of the free boards winner. Please send me your full address in a privet message.
@dtl19
@dtl19 6 жыл бұрын
Web learning woohoo! 😀
@vincentmetallive
@vincentmetallive 4 жыл бұрын
@@Weblearning1 would the optimizer not discard this?
@Weblearning1
@Weblearning1 4 жыл бұрын
Can you please explain your question?
@Shubham-po2tp
@Shubham-po2tp 3 жыл бұрын
Can we use for loop, while loop, function call like In Arduino Here in this software hal using
@Weblearning1
@Weblearning1 3 жыл бұрын
You can just read the GPIO.
@Shubham-po2tp
@Shubham-po2tp 3 жыл бұрын
@@Weblearning1 ok sir
HAL: #3 How to - UART
6:37
Web learning
Рет қаралды 74 М.
Interrupts | #8 STM32 GPIO button interrupt
23:48
Terminal Two
Рет қаралды 53 М.
когда повзрослела // EVA mash
00:40
EVA mash
Рет қаралды 4,5 МЛН
Каха и суп
00:39
К-Media
Рет қаралды 5 МЛН
🤔Какой Орган самый длинный ? #shorts
00:42
Happy 4th of July 😂
00:12
Pink Shirt Girl
Рет қаралды 61 МЛН
34. STM32CubeIDE Button debounce. Interrupt with STM32F103C8T6
7:15
MicroPeta by Nizar Mohideen
Рет қаралды 20 М.
How to create delay in nano/micro seconds using timers in stm32
7:41
ControllersTech
Рет қаралды 45 М.
Tutorial on STM32 External Interrupts and callback funktions
24:31
Raspberry Pi - How to Handle GPIO Interrupts with Python 3
14:57
Robotics Back-End
Рет қаралды 14 М.
STM32CubeIDE basics - 04 EXTI HAL lab
15:34
STMicroelectronics
Рет қаралды 45 М.
Interrupts on Cortex M - NVIC (demonstrated on STM32) | VIDEO 34
34:24
Matej Blagšič
Рет қаралды 16 М.
Arduino Basics 101: Hardware Overview, Fundamental Code Commands
8:02
Receive data using UART in STM32 || Poll || Interrupt || DMA
14:07
ControllersTech
Рет қаралды 122 М.
Hacker's Guide to UART Root Shells
17:40
Flashback Team
Рет қаралды 467 М.
HAPPY BIRTHDAY @mozabrick 🎉 #cat #funny
0:36
SOFIADELMONSTRO
Рет қаралды 10 МЛН
Сумасшедший бассейн с волнами в Китае
0:16
Короче, новости
Рет қаралды 9 МЛН
Look at two different videos 😁 @karina-kola
0:12
Andrey Grechka
Рет қаралды 9 МЛН
Good dad 🥰 #demariki
0:17
Demariki
Рет қаралды 14 МЛН
Пресс Боксера Тяжеловеса и Твоего Тренера
0:20
Голову Сломал
Рет қаралды 4,9 МЛН