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.
}
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
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- 【CH579M-R1】+KEY control LED program
- The third pit of domestic FPGA chip logic analyzer prompts Can not connect to JTAG server
- Has anyone used a 15v to 3.3v converter?
- Unboxing the imxm8plus development board from PHYTEC
- EEWORLD University ---- OpenCV 3 with Python 3 Tutorial
- Siemens 230RC opens for 3 seconds and closes for 3 seconds
- [Environmental Expert's Smart Watch] Part 10: Status Light and Mode Switching
- Disassembly of 3.0 expansion dock, PD to HDMI conversion chip Bridgestone PS176HDMQFN48GTR2-B0 schematic diagram reference
- Three issues about LDO load regulation, linear regulation and voltage drop
- How to release the object is part of a locked union