Using STM8's TIM1 to implement a running light experiment (using an external clock)

Publisher:RainbowJoyLatest update time:2016-10-20 Source: eefocusKeywords:STM8  TIM1 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
The internal and external clocks are automatically switched, and the effect of external clock failure can be observed (external clock changes quickly, internal clock changes slowly). The clock initialization procedure is as follows:

void CLK_Init(void)
{
    //CLK_CKDIVR &= ~0x10;//Clock divider register
    //CLK_CKDIVR |= 0x01;
    CLK_ECKR=0x03;//External clock register External clock is ready, external clock is on
    
    CLK_SWCR=0x02;//Switch control register enables switching mechanism
    CLK_SWR=0xB4;//Master clock switch register selects HSE as the master clock sourcewhile
    (!(CLK_SWCR & 0x08)); /* Wait for switch done If this statement is not present,
    the switch successful. The internal clock is used during simulation. When the simulation is stopped, the external clock is switched to, but
    after power-on or reset, it returns to the internal clock state (Debug mode)*/
  
  /* verify the external clock is selected (optional) */
    //if (CLK_CMSR != 0xB4)        
      //while(1);
    CLK_CSSR=0x01;//Clock security system register
    
}

Keywords:STM8  TIM1 Reference address:Using STM8's TIM1 to implement a running light experiment (using an external clock)

Previous article:Design of ECG Detection System Based on SPCE061
Next article:STM8 GPIO output experiment - lighting up LED (software delay)

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

Build STM8 development environment under Linux
Use SDCC+STM8Flash+STLink to build Linux development STM8 development environment. Corresponding MCS51, LPC and the like can also use SDCC 1. Install SDCC $ sudo apt-get install sdcc 2. Install stm8flash git clone https://github.com/vdudouyt/stm8flash.git cd stm8flash make sudo make install 3. Install STlink dri
[Microcontroller]
STM8 GPIO driver
The peripherals of the chip generally follow these processes: GPIO, external interrupt, timer, serial port, ADC, IIC, SPI. Below I will write according to each mode.    First of all, GPIO. STM8's GPIO has a multiplexing function. This sentence tells us that we must configure the IO multiplexing function before we can
[Microcontroller]
STM8 GPIO driver
STM8 real-time clock PCF8563 and infrared door entry reminder
Table of contents: Overall Design 1. Basic hardware DIY design 1) Overall schematic diagram 2) External RTC circuit 3) PCB circuit 4) 3D_PCB 2. MCU Programming 1) PCF8563 I2C communication program 2) Main function logic 3. Effect display 1) Top-level diagram of the physical circuit 2) Physical circuit bottom dia
[Microcontroller]
STM8 real-time clock PCF8563 and infrared door entry reminder
Why can IAR for STM8 not configure the clock?
When I first started learning STM8, I followed the online tutorial to create an IAR project, then downloaded an official firmware library and made a case template. The function was super simple, just a flashing LED light, and the main function had just this content: void main(void) { /* Initialize I/Os in Output Mode
[Microcontroller]
The problem of occasional jump errors when reading AD values ​​from STM8
When debugging the AD function of STM8S103K3T6, it was found that when the temperature changes rapidly (hair dryer simulation), the read AD value will occasionally jump, and the position of the appearance is relatively fixed; the AD clock is set to 2Mhz, and the data is collected every 100ms, single-channel collection
[Microcontroller]
The problem of occasional jump errors when reading AD values ​​from STM8
STM8 programming
The following problems were encountered when programming STM8 recently 1.Error : Cannot communicate with the tool. Wrong tool selection or check tool power supply or check that a previous session is closed. Error : PROGRAM MEMORY programming failed. There is a problem with the link to stlink, There are two case
[Microcontroller]
Why simple software delay does not work when developing STM8 with IAR
Recently, I was fortunate enough to take over the project left by the previous engineer. The MCU I chose was STM8L151XX, and the development tool I used was IAR. After opening the ancestral code, I read it through and burned it into it with ST-Link to run the program. As a result, I found that the effect was not consi
[Microcontroller]
Why simple software delay does not work when developing STM8 with IAR
Use IAR to create stm8 project records
Open the project 2. Create New Project… 3. Empty project 4. Save the project to the specified folder The newly completed projects are as follows: 5. Configure Options 6. Select stm8 device 7. Output Hex file 8. Linker Configuration 9. Debugger 10. Add files and groups 11. Add STM8S_StdPeriph_Driver
[Microcontroller]
Use IAR to create stm8 project records
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号