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.
@dragosmakovei5 жыл бұрын
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); }
@mutexembedded22065 жыл бұрын
Correct, thanks for sharing
@halradhi5 жыл бұрын
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)
@Nikola9933115 жыл бұрын
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.
@MrPnew15 жыл бұрын
@@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"
@Nikola9933115 жыл бұрын
@@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.
@omaralshishani97246 жыл бұрын
thank you, very useful video keep up the good work
@guruG5092 жыл бұрын
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?
@mutexembedded22062 жыл бұрын
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_Denaro5 жыл бұрын
Hi, Thx for this tutorial. I don't have clear why do you remove the code of the Rcc oscillator?
@sudhansumtripathy Жыл бұрын
hi, thank you for the video , how many ports are there and how to know which pin is in which port
@samiratalebi78035 жыл бұрын
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.
@fares36515 жыл бұрын
bad idea :,) start with Arduino first
@user-ti3ne8xw6f5 жыл бұрын
I think the if in line 118 is not necessary
@yashwanthl17685 жыл бұрын
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
@mutexembedded22065 жыл бұрын
Hi, This connects straight to an NRST pin on the MCU.
@artiny166 жыл бұрын
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
@mutexembedded22066 жыл бұрын
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
@artiny166 жыл бұрын
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 Жыл бұрын
@@artiny16 yeah, seeing the same thing and also rectified it the same way. Still investigating this. I'm a noob.
@rathtanaduong52236 жыл бұрын
Is there a documentation that I can refer to for the syntax when writing code? Thanks
@AyoubAyoub-qc1hr6 жыл бұрын
Hi, did you find any for the HAL API?
@stevergr90393 жыл бұрын
Please work on the audio quality. It’s very hard to understand.
@mutexembedded22063 жыл бұрын
Sure, thanks
@aeonsalgado43294 жыл бұрын
What is GPIOC? Where is explained where that part of the hadware it is?
@aeonsalgado43294 жыл бұрын
In the archive "gpio.c" explain all of this.
@mutexembedded22064 жыл бұрын
@@aeonsalgado4329 Correct
@sushantchauhan57554 жыл бұрын
Hi Can you please give the code of driver level without using HAL