STM8S clock switching self-study notes 2

Publisher:TranquilSoulLatest update time:2021-09-07 Source: eefocusKeywords:STM8S Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Last time it was automatic switching, this time write manual switching

Main registers

CLK_SWCR

CLK_SWR

CLK_CMSR


Manual Switch

1. CLK_SWR writes u8 value, SWBSY hardware is set in CLK_SWCR

2. The user software waits until the target clock is stable. The meaning of CLK_SWCR SWIF depends on the state of the SWEN bit. If SWIEN is 1, an interrupt is generated.

3. At the time point selected by the user software, set SWEN in CLK_SWCR to execute the switch

#include "stm8s.h"
#define uint unsigned int
void Delay(uint x)
{
  while(x--);
}
void main()
{
  
 // u8 i;
  GPIO_Init( GPIOG,GPIO_PIN_0,GPIO_MODE_OUT_PP_HIGH_SLOW);
 CLK_ClockSwitchConfig(CLK_SWITCHMODE_MANUAL,CLK_SOURCE_HSE,ENABLE,CLK_CURRENTCLOCKSTATE_ENABLE);
 rim();
 while(1)
 {
    GPIO_WriteReverse(GPIOG,GPIO_PIN_0);
    Delay(50000);
  
 }
 

}
#ifdef USE_FULL_ASSERT
void assert_failed(u8* file, u32 line)
 {
   while (1)
   {
   }
 }
#endif


INTERRUPT_HANDLER(CLK_IRQHandler, 2)
{
  CLK_ClearITPendingBit(CLK_IT_SWIF);// In order to detect unexpected events during development,
    
  CLK_ClockSwitchCmd(ENABLE);// it is recommended to set a breakpoint on the following instruction.
 
}


Keywords:STM8S Reference address:STM8S clock switching self-study notes 2

Previous article:STM8S clock switching self-study notes
Next article:STM8S ADC self-study notes 1

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

STM8S can filter summary
It’s not easy to learn something. It took me 6 hours to finally understand filtering. The key was that I didn’t find a suitable example. STM8S provides six 32-bit filter registers. We will only discuss 32-bit address filtering for now. These six 32-bit filters can be filtered in list mode, that is, the identifiers set
[Microcontroller]
STM8S can filter summary
STM8S low power consumption power management
1STM8S power consumption source STM8S power consumption is divided into static power consumption and dynamic power consumption. Static power consumption: mainly generated by the bias current and leakage current of the transistor. Dynamic power consumption: depends on the supply voltage and operating clock frequ
[Microcontroller]
Two methods of developing SPI with stm8s
1: void GPIO_Configuration(void) Add GPIOA configuration void GPIO_Configuration(void) {      GPIO_DeInit(GPIOD);   /* Configure PD0 (LED1) as output push-pull low (led switched on) */   GPIO_Init(GPIOD, GPIO_PIN_0, GPIO_MODE_OUT_PP_LOW_FAST);   /* GPIOD reset */   GPIO_DeInit(GPIOC);   /* Configure
[Microcontroller]
Two methods of developing SPI with stm8s
Notes on STM8S and STM8L debugging serial port interrupts
Note on STM8L serial port interruption  When debugging the PM2.5 sensor GP2Y1051, it is found that data can be received at the beginning of simulation, but if it is paused, it cannot receive data. In fact, it only receives complete data once. Solution if(USART_GetITStatus(USART1, USART_IT_RXNE)) { RecevieData = 
[Microcontroller]
STM8S MAX7219 dot matrix module driver chip program
The following is the .h file: #ifndef __MAX7219_H #define __MAX7219_H #include "stm8s_gpio.h" #include "stm8s.h" #include iostm8s103f3.h #include intrinsics.h #include "tim1.h"   #define uchar unsigned char #define uint  unsigned int #define count 8     void Init_MAX7219(void); void MAX7219_Init(void); void Write
[Microcontroller]
STM8S MAX7219 dot matrix module driver chip program
STM8S_010_I2C read and write EEPROM (hardware method)
Ⅰ Written in front I believe that those who have read the previous article "A Deeper Understanding of I2C Bus, Protocol and Application" have a certain understanding of I2C. That article is about using microcontroller IO to simulate I2C to implement read and write operations. This article will describe the hardware
[Microcontroller]
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号