Тёмный
No video :(

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

Mutex Embedded
Подписаться 22 тыс.
Просмотров 40 тыс.
50% 1

Опубликовано:

 

22 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 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.
@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.
@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
@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.
@stevergr9039
@stevergr9039 3 года назад
Please work on the audio quality. It’s very hard to understand.
@mutexembedded2206
@mutexembedded2206 3 года назад
Sure, thanks
@user-ti3ne8xw6f
@user-ti3ne8xw6f 5 лет назад
I think the if in line 118 is not necessary
@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
@sudhansumtripathy
@sudhansumtripathy Год назад
hi, thank you for the video , how many ports are there and how to know which pin is in which port
@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?
@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.
@manofmesopotamia7602
@manofmesopotamia7602 5 лет назад
فديوهات مفيدة عاشت ايدك
@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
@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?
@sushantchauhan5755
@sushantchauhan5755 4 года назад
Hi Can you please give the code of driver level without using HAL
@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?
Далее
STM32F4 Nucleo Tutorial- Control GPIO LED Switch
19:00