How to use STM8 timer

Publisher:糖果龙猫Latest update time:2021-11-29 Source: eefocusKeywords:STM8 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The main function of the timer is to record time. For example, the rice cooker automatically stops heating after 20 minutes, which is accomplished by the timer. In fact, the timer is just like the alarm clock we use in our daily life. Today, we will take the widely used STMicroelectronics STM8 microcontroller as an example to share with you how to use the timer.

How to use STM8 timers?

Methods/Steps

  1. Use IAR FOR STM8 to open a project.

    How to use STM8 timers?

  2. Initialize the timer.

    How to use STM8 timers?

  3. And set to allow timer interrupt, which means that when the timer time is up, it will enter an interrupt.

    How to use STM8 timers?

  4. Some flag bits are set and some necessary functional operations are performed in the timer interrupt.

    How to use STM8 timers?

  5. In this way, the program will enter the interrupt cycle over and over again, and by counting the number of interrupts, a longer timing function can be completed.

    How to use STM8 timers?

  6. 6

    Each interrupt of the timer can also be used as the system clock to switch whether some tasks are executed or not.

    How to use STM8 timers?

    END


Keywords:STM8 Reference address:How to use STM8 timer

Previous article:stm8s105k4 microcontroller PWM wave configuration
Next article:3. STM8 study notes-----GPIO operation

Recommended ReadingLatest update time:2024-11-16 12:44

STM8 TIM2 timer problem
The chip used is STM8S103F3P6, the compiler is IAR, and the program code is as follows: // #include "iostm8s105c6.h" #include "iostm8s103F3.h" // Very important  void DelayMS(unsigned int ms) {   unsigned char i;   while(ms != 0)   {     for(i=0;i 250;i++)     {     }     for(i=0;i 75;i++)     {     }     ms--;   
[Microcontroller]
STM8 Hardware Design Considerations
The external interrupt of STM8 is different from that of STM32. Each port PX has only one interrupt.    2. ADC 1) Additional AIN12 analog input is not selectable in ADC scan mode or with analog watchdog. Values ​​converted from AIN12 are stored only into the ADC_DRH/ADC_DRL registers 2) About the connection method
[Microcontroller]
STM8 Hardware Design Considerations
STM8 clock switching
HSE, HSI, and LSI can all be used as the system's main clock source. After the STM8 microcontroller is reset, the default frequency division of HSI is 8 as the system's main clock. The reason is that the HSI has a short stabilization time, and its frequency division of 8 can ensure that the system starts safely under
[Microcontroller]
STM8 clock switching
iar for stm8 error Error[Li005]: no definition for "assert_failed" solution
Building configuration: STM8S_DEMO - Debug  Updating build tree...  Linking  Error : no definition for "assert_failed"   Error while running Linker  Total number of errors: 1  Total number of warnings: 0  void assert_failed(u8* file, u32 line); This function is only declared in the "stm8s_conf.h" file and is used
[Microcontroller]
STM8 EEPROM unlocking is repeatable
After the STM8 EEPROM is reset, if you want to write data, you must unlock it first, otherwise you will not be able to write data. Unlocking means writing to FLASH_DUKR in sequence: The first hardware key: 0xAE Second hardware key: 0x56 Two bytes of data. At this time, the DUL bit in FLASH_IAPSR will become 1,
[Microcontroller]
MCU timer (timer0 working mode 2)
; Let the LED light change every R1ms COUNT EQU 92; for a crystal oscillator of 11.0592, 92 is equivalent to 100us LED EQU P1.1   ORG 0000H   MOV R0,#00H   DJNZ R0,$     MOV SP,#60H   MOV R1,#00H ; Use R1 as the overall count and use   MOV R2,#00H   //MOV A,TMOD   //ANL A,#11110000B    //CLR ACC.3   //CL
[Microcontroller]
STM8 block operations
I went the wrong way looking for her, and when I looked back, she was in the library function!     I have never found a library function that specifically analyzes eeprom block programming on the Internet. Either the library function is too bad, and it is better to write it yourself, or it is Wang Zhijie's routine.
[Microcontroller]
s3c6410 hardware WATCHDOG TIMER watchdog timer
  First, let's briefly describe the working process of the watchdog. The watchdog is actually a timer with a counter inside. Every time a clock signal arrives, the counter register decreases by one. If it decreases to 0, the system will restart; if the system sets the counter to a larger value before it decreases to 0,
[Microcontroller]
s3c6410 hardware WATCHDOG TIMER watchdog timer
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号