No video

STM32-Nucleo - Keil 5 IDE with CubeMX: Tutorial 2 - Push button

  Рет қаралды 40,128

Mutex Embedded

Mutex Embedded

6 жыл бұрын

Пікірлер: 38
@asagk
@asagk 5 жыл бұрын
If you have an external push button, you add a resistor in series and a capacitor to refV (0V) to it, called "low pass filter", and you are done with the debouncing.
@dragosmakovei
@dragosmakovei 5 жыл бұрын
For toggling the pin you can also use this kind of Approach //This toogle initialization means wether the led wil be on or off for the first press bool toggle = true; if(HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_13) == GPIO_PIN_RESET) { toggle = !toggle; //This delay here because the frequency of the board is so high so you need time to release your finger. //Else you wouldn't be able to see any change of the led HAL_Delay(100); HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, toggle); }
@mutexembedded2206
@mutexembedded2206 5 жыл бұрын
Correct, thanks for sharing
@halradhi
@halradhi 5 жыл бұрын
Thank you very much for the great tutorial. Small note: I believe there is no need for the "debouncing code" since the push button in the nucleo f401re board is attached to a pullup resistor (4K7) and 100nF capacitor. Keep up the good work (Y)
@Nikola993311
@Nikola993311 5 жыл бұрын
You are partly correct. This would filter out any signal with frequency higher than around 2.2kHz. You can check Jack Ganssle's website, there is a article he did on this theme. He came to a conclusion through series of experiments that there are switches that bounce with period greater than 153ms which is of course rare but possible. For microswitch this time can be around 1.2ms ~= 833Hz, this would not be filtered out. So you are correct that this kind of debounce doesn't solve the bouncing problem because the 5us delay is doing the same thing that is already solved with integrated LP filter.
@MrPnew1
@MrPnew1 5 жыл бұрын
@@Nikola993311 sorry to intrude but you are a recent poster here and seem to know about this stuff. I asked a question of the OP but doubt that he will see it. Can I ask you the same thing please. The question was "@3:33 I have exactly the same problem. My LED is on and then goes off when I press the LED, same as yours. I changed my code to yours and it does exactly the same thing. You say that quote "you can change this by swapping these codes together" I really do not understand what you are saying sorry The second and third lines of the while statement are the same except one has GPIO_PIN_SET and the other GPIO_PIN_RESET. I tried swapping them but it made no difference, Please does someone know how to fix this as I have tried everything. Thanks"
@Nikola993311
@Nikola993311 5 жыл бұрын
@@MrPnew1 Hi I'll try to help. What he's saying is that he thought that the button is active HIGH i.e. that when he press the button the pin would read '1'(or SET state) and it should be connected like that if we want to preserve energy, but in this case button is active LOW i.e. when he press the button the pin would read '0'(or RESET state). So you should change the GPIO_PIN_SET to GPIO_PIN_RESET inside if statement :). I hope this helped. This way when we press button the LED will be ON and when the button is not pressed the LED will be off and not the other way round.
@omaralshishani9724
@omaralshishani9724 6 жыл бұрын
thank you, very useful video keep up the good work
@guruG509
@guruG509 2 жыл бұрын
Sir, i have a question, that whether in industry, where there are a lot of sensors and actuators, doe they use HAL library, or bare metal, or both are used according to application demand?
@mutexembedded2206
@mutexembedded2206 2 жыл бұрын
Hi, HAL is just part of the BSP (Board Support Package), STM at this case. If it is reliable enough for the intended application, which in practice it is, yes it is widely used.
@Fabio_Denaro
@Fabio_Denaro 5 жыл бұрын
Hi, Thx for this tutorial. I don't have clear why do you remove the code of the Rcc oscillator?
@sudhansumtripathy
@sudhansumtripathy Жыл бұрын
hi, thank you for the video , how many ports are there and how to know which pin is in which port
@samiratalebi7803
@samiratalebi7803 5 жыл бұрын
Hi, Thx for this tutorial. I have done this but i have error with If...else . That says : else is error Syntax. I'm new with programming and i cannot find the reason.
@fares3651
@fares3651 5 жыл бұрын
bad idea :,) start with Arduino first
@user-ti3ne8xw6f
@user-ti3ne8xw6f 5 жыл бұрын
I think the if in line 118 is not necessary
@yashwanthl1768
@yashwanthl1768 5 жыл бұрын
Nice video User bottom is connected to pin 13 right I want to know what is the pin number of reset bottom in stm 32 nucleo
@mutexembedded2206
@mutexembedded2206 5 жыл бұрын
Hi, This connects straight to an NRST pin on the MCU.
@artiny16
@artiny16 6 жыл бұрын
helo, very good tutorials, but I have question, why dont work if I want the first example to try out....but in default state I want to have the LED in OFF position and only ON(LED) when I push the button
@mutexembedded2206
@mutexembedded2206 6 жыл бұрын
Hi, Push button on the Nucleo is Active Low; When pressed -> Reads 0 When released -> Reads 1 LED is normal High -> LED ON Low -> LED OFF
@artiny16
@artiny16 6 жыл бұрын
thank you for the response. So,... there are different state in default when is the whole board in high or low voltage ? Or something else is to determine why is in default state the LED is ON when start the program at 3:28 in the video? something in setting is PULL HIGH or something this ? I modified the program, the if is now not in == but is != ...and now work as I want. if( HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_13) != GPIO_PIN_SET)
@TheWfurst
@TheWfurst Жыл бұрын
@@artiny16 yeah, seeing the same thing and also rectified it the same way. Still investigating this. I'm a noob.
@rathtanaduong5223
@rathtanaduong5223 6 жыл бұрын
Is there a documentation that I can refer to for the syntax when writing code? Thanks
@AyoubAyoub-qc1hr
@AyoubAyoub-qc1hr 6 жыл бұрын
Hi, did you find any for the HAL API?
@stevergr9039
@stevergr9039 3 жыл бұрын
Please work on the audio quality. It’s very hard to understand.
@mutexembedded2206
@mutexembedded2206 3 жыл бұрын
Sure, thanks
@aeonsalgado4329
@aeonsalgado4329 4 жыл бұрын
What is GPIOC? Where is explained where that part of the hadware it is?
@aeonsalgado4329
@aeonsalgado4329 4 жыл бұрын
In the archive "gpio.c" explain all of this.
@mutexembedded2206
@mutexembedded2206 4 жыл бұрын
@@aeonsalgado4329 Correct
@sushantchauhan5755
@sushantchauhan5755 4 жыл бұрын
Hi Can you please give the code of driver level without using HAL
@manofmesopotamia7602
@manofmesopotamia7602 5 жыл бұрын
فديوهات مفيدة عاشت ايدك
@carjankari7268
@carjankari7268 6 жыл бұрын
please provide link for code
@MrPnew1
@MrPnew1 5 жыл бұрын
I posted the main.c in one of my comments.
@deivislugo2865
@deivislugo2865 3 жыл бұрын
@@MrPnew1 where is it?
STM32 Nucleo - Keil 5 IDE with CubeMX: Tutorial 7 - I2C interface
10:26
Smart Sigma Kid #funny #sigma #memes
00:26
CRAZY GREAPA
Рет қаралды 19 МЛН
天使救了路飞!#天使#小丑#路飞#家庭
00:35
家庭搞笑日记
Рет қаралды 72 МЛН
Harley Quinn's desire to win!!!#Harley Quinn #joker
00:24
Harley Quinn with the Joker
Рет қаралды 9 МЛН
Hardest Repair Ever! Fluke 8508A 8.5 Digit Reference Multimeter
43:05
These Illusions Fool Almost Everyone
24:55
Veritasium
Рет қаралды 2,2 МЛН
STM32 Guide #2: Registers + HAL (Blink example)
30:02
Mitch Davis
Рет қаралды 192 М.