GPIO ON-delay input application [GPIO practical example for STM32]
Table of contents
After the successful "LED-blingking", I will introduce the application of anti-chattering on-delay input and unused pin processing examples to practical examples of STM32GPIO input.
This program adds an on-delay input function and processing of unused pins to prevent chattering.
Chattering is a mechanical vibration of the contacts that causes the switch to turn on and off at very short intervals when the switch is input.
An ON-delay input is one that is turned ON after a certain period of time after being input. Inputs shorter than the ON-delay period (⊿) are ignored.
The ON-delay input is familiar to those familiar with PLC programming for industrial equipment control, but it is also useful in embedded applications.
This application has an on-delay timer that turns the output ON 1000ms after the switch is turned ON, using a timer that waits for a period of time set by delay_ms().
Since delay_ms(1) is used, the infinite loop cycles for 1ms. delay_ms() is a function defined in delay.c. To use this function, copy delay.c and delay.h to the same location as the application program and call it in the header file delay.h.
Processing of unused pins
In most cases, only some of MCU's pins are used and the rest are not. We define the pins to be used, but what should we do with the unused pins?
Although unused pins do not cause any problem in MCU function itself even if nothing is processed to them, they may malfunction or be destroyed by noise, etc. Therefore, it is recommended to define them as inputs or outputs and process them, especially when they are incorporated into a product.
There are various theories on how to handle unused pins, but here the pins are explicitly designated as outputs and also specified as L-level.