stm8L touch library usage tutorial

Publisher:温馨生活Latest update time:2020-01-16 Source: eefocusKeywords:stm8L Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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.

Keywords:stm8L Reference address:stm8L touch library usage tutorial

Previous article:stm8s_atomthread
Next article:STM8S Program Transplantation Experience

Recommended ReadingLatest update time:2024-11-16 13:03

Tutorial on using STM8L's own bootloader
The microcontroller model used by the author is: STM8L151C8T6, with 64kFlash Download addresses for files that may be used in this tutorial: Official firmware and instruction manual: https://www.stmcu.com.cn/Index/search?search_keywords=UM0560 Baidu network disk link: https://pan.baidu.com/s/1XyBWJIhHsuwWgwGNuHa
[Microcontroller]
Tutorial on using STM8L's own bootloader
Why does the STM8L external interrupt operate in an endless loop?
The STM8L series MCU is a low-power MCU launched by ST. Compared with the STM8S series, the power consumption is much lower, but the internal structure is also much reduced. Be sure to read the manual carefully when using it. This is the first time I use STM8. Since the functions are not very complicated, I did not wan
[Microcontroller]
Why does the STM8L external interrupt operate in an endless loop?
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号