1. Check the touch library documentation and select the chip according to your needs (mainly supporting several keys): STMTouch Driver User Manual
One channel is one button. For example, STM8L101F supports 3 buttons. You can add more buttons by expanding the button. For details, refer to:
Guide to increasing the number of touch sensor buttons.pdf
2. Download the corresponding official touch library STM8L_STMTouch_Lib_V1.1.0, and copy the following two folders to your own project folder
3. Select a project similar to your own project to open. For example, if I want to make a touch light with 1-4 buttons, I choose STM8L101K3_Ex01
Open: Projects - Examples - STM8L101K3_Ex01 - EWSTM8 (I used IAR) - Example.eww
4. Run Make after opening. Generally, make succeeds with 0 errors.
5. Open the corresponding config file. In my case, it is the tsl_conf_stm8l.h file. The following settings need to be made in it:
There are many parameters in this file. I will configure them when I use them later. I am not sure about them now.
6. Open tsl_user.c, touch the application function of the library, make modifications, and read the program step by step. I have the habit of adding comments, which is convenient for looking back.
Here's how I first read a program, breaking it down step by step:
7. After reading the user.C file, you will have a general idea of the parameters of the touch library. Generally speaking, it involves the following preparation steps:
Determine the pins according to the requirements and set the number in the conf file. Set the channels, banks, groups, and objects in the user. Finally, get the user function. Call the main function in main or interrupt to determine which button is triggered. For details, you need to go through the main of the routine:
,
Now that we have finished reading the main function, let's continue to look at the functions below:
After checking main.C, we roughly know the mode of this library. In the action user function, we can judge which button is pressed to execute the desired program. In addition, the touch library has a TIM4 heartbeat timer. We can modify the code, change the time or replace the timer as needed. We can also execute some process codes in the timer interrupt as needed.
Load the program into the board and it executes well. The sensitivity can be adjusted by the relevant parameters in conf.H. You can try it out.
I went through it quickly this time, focusing on the function implementation, without going into detail. Some parts of the official library code are confusing, and some key parts are not explained as they should be. The experience is average. Compared with the dedicated touch IC of general manufacturers, the advantage is good scalability, most STM8 can be used. I will try to transplant the touch solution to other chips such as 51 when I have time, and we will communicate together then.
Previous article:stm8s_atomthread
Next article:STM8S Program Transplantation Experience
Recommended ReadingLatest update time:2024-11-16 13:03
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Ghost video sound
- Wire Harness Tester Related Operation & Application Video (Continuously Updated)
- TMS320C66x dual loop and multiple loop optimization summary
- 【TI recommended course】#TI millimeter wave radar technology introduction#
- 【micropython】STM32 will support arbitrary FS
- Global variables in embedded system programming
- PWM generated voltage calculation table
- Help, I need to exchange an E coin, I still need one
- The official WeChat group of the community has been established: you can chat about Microchip live broadcast and PIC microcontrollers
- C6000 Code Generation Tools - Compiler