A brief introduction to the STM8 RC touch library

Publisher:静静思索Latest update time:2020-03-05 Source: eefocusKeywords:STM8 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The touch detects that a key is pressed and the calling process is: TSL_Action -> TSL_SCKEY_P1_Acquisition() -> TSL_IO_Acquisition() -> TSL_SCKey_Process() -> TSL_SCKey_DetectedTreatment(), where TSL_Action() and TSL_SCKey_Process() have other state changes and processing.


The TSL_IO_Acquisition() function is a charge and discharge time detection function. The most important variables should be the charge and discharge time and the number of times it is detected that the value exceeds the preset range. They will be used outside the function, namely FinalMeasurementValue and RejectionCounter.


void TSL_IO_SW_Burst_Wait_Vil(void)//Only view the contents of IAR compiler

{



#if defined(_COSMIC_)

......

#elif defined(_IAR_)

  __asm("ld a, S:AcquisitionBitMask"); //Put AcquisitionBitMask into a

  __asm("ldw x, S:sTouchIO"); // Put sTouchIO into x Load word (16 bits)

  __asm("incw x"); //Add a word

  // Loop = 1 + 1 + 2 + 2 + 2 cycles = 8 cycles

  __asm("WaitForVil:");

// To be sure that the loop last 8 cycles the first instruction must be a 1-byte instruction

// This is to be sure it is fully fetched in 1 cycle. The second instruction must be shorter than 4 bytes.

// If this not the case, the code must be aligned. 

  __asm("bcp a, (x)"); // 1 cycles logical comparison

  __asm("jreq ??EndWaitForVil"); //Jump to EndWaitForVil

  __asm("ldw y, TIMACQ_CNTR"); // 2 cycles; hw counter also used for timeout ...

  __asm("cpw y, #0x0E00"); // 2 cycles; Timeout compare word value comparison

  __asm("jrult ??WaitForVil");

  __asm("EndWaitForVil:");

#else //_RAISONANCE_

......

#endif

}


The general meaning of this function is to detect the level of the corresponding pin until the same level or timeout jumps out. The value of the TIMACQ_CNTR counter should be loaded in FinalMeasurementValue (I don’t know if it is correct, please correct me)

Keywords:STM8 Reference address:A brief introduction to the STM8 RC touch library

Previous article:stm8l wake-up operation encountered a problem
Next article:Detailed explanation of STM8S touch button firmware library

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

STVD+Cosmic builds STM8 development environment
1. Download STVD from the official website and install it Because STVD only supports assembly language, you also need to install the Cosmic compiler to support C language 2. Download Cosmic from the official website and install it Register on the official website and get a 1-year free license 3. Configure Cosmic p
[Microcontroller]
STVD+Cosmic builds STM8 development environment
Main features of STM8 I2C interface
STM8 I2C interface The I2C (Inter-Chip) bus interface connects a microcontroller to a serial I2C bus. It provides multi-master functionality and controls all IC bus specific timing, protocols, arbitration, and timing. Both standard and fast modes are supported. STM8 I2C main features Parallel Bus/I2C Bus Protocol C
[Microcontroller]
[STM8] - External clock + internal clock switching
First, take a look at the clock structure diagram of STM8S103K3, which can help you understand it well.  There are several clocks here, which are the clocks marked in the figure, and you need to clarify them: fHSE: External high-speed crystal oscillator clock, which is generated by an external crystal oscillator a
[Microcontroller]
STM8 Assembly Learning Notes 2: Development Environment
Preface As far as I know, there are two development platforms for STM8: STVD from ST and IAR for STM8. I haven't tried STVD. Anyway, IAR feels OK, and it has all the necessary functions, but the interface is not very user-friendly. I guess it's because of the low version. Since my eyes hurt from staring at the screen
[Microcontroller]
STM8 Assembly Learning Notes 2: Development Environment
Low-capacity STM8 Modbus protocol transplantation and tailoring
1. Download freeModbus open source package Generally, the development environment used by STM8 is IAR, so here we will talk about porting FreeModbus under IAR.  Download freemodbus-v1.5.0, the official download address is http://www.freemodbus.org/ and find Download  Click freemodbus-v1.5.zip to download.  2. In
[Microcontroller]
Low-capacity STM8 Modbus protocol transplantation and tailoring
STM8 MCU software determines the reset source
Let me tell you about the port remapping of STM32 microcontroller. Here we take the remapping of USART1 as an example. There are many I/O ports on STM32, and there are also many built-in peripherals such as I2C, ADC, ISP, USART, etc. In order to save lead pins, these built-in peripherals basically share pins with I/
[Microcontroller]
STM8 and Assembly Language (17) - Buzzer
Buzzers are very common in microcontroller application systems and are often used to implement alarm functions. For this reason, STM8 has specially integrated a buzzer module, which is very convenient to use. When using the buzzer module, first turn on the low-speed RC oscillator on the chip (it should also be possi
[Microcontroller]
STM8 timer TIM1-TIM6 usage details and experimental procedures
STM8 Timer Overview STM8S provides three types of TIM timers: advanced control type (TIM1), general type (TIM2/TIM3/TIM5) and basic timer (TIM4/TIM6). Although they have different functions, they are all based on a common architecture. This common architecture makes it very easy and convenient to design applications
[Microcontroller]
STM8 timer TIM1-TIM6 usage details and experimental procedures
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号