There are 4 types of stm8 clock sources:
1. 16MHz high-speed internal clock source HSI
2. 1 to 16MHz high-speed external clock source HSE
3. 32.768KHz low-speed external clock source LSE
4. 38KHz low-speed internal clock source LSI
These 4 clock sources can be used as system clocks. You can also use an oscilloscope to measure pin 59 to see if the output clock frequency is correct. Before measuring, you need to make the following settings:
void main(void)
{
GPIO_Init(GPIOC, GPIO_Pin_4, GPIO_Mode_Out_PP_High_Fast);
//CLK_CCOConfig(CLK_CCOSource_HSI, CLK_CCODiv_1); /* 16MHz */
CLK_CCOConfig(CLK_CCOSource_HSI, CLK_CCODiv_16); /* 1MHz */
while (1);
}
If HSI is selected as the clock output, the measured value is 16MHz without frequency division, and 1MHz if it
is divided by 16. The system clock uses HSI by default, and is divided by 8, that is, 2MHz. You can use the function CLK_GetClockFreq() to get the system clock, for example:
void main(void)
{
uint32_t freq = CLK_GetClockFreq();
while (1);
}
It's strange. When I check the value of the variable freq through the watch window during debugging, the above writing is correct. If I change it to the following writing:
void main(void)
{
uint32_t freq;
freq = CLK_GetClockFreq();
while (1);
}
Then there will be a problem when checking the freq value. I don't know why yet, but it may be related to the development environment.
Of course, you can also use the CLK_SYSCLKDivConfig() function to set the frequency division of the system clock. For example, if you do not divide the frequency:
CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_1);
then after setting, the system clock will be 16MHz.
Previous article:The difference between CY and OV microcontrollers
Next article:stm8 rtc clock
Recommended ReadingLatest update time:2024-11-16 12:54
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
- How to analyze which solution is better when two rectifier bridges are connected together?
- [RVB2601 Creative Application Development] Introduction and use of RVB2601 WiFi networking to obtain weather information
- IGBT Driver
- Renesas Electronics RL78/G11 target board free application, participate in the application can also win a JD card!
- Faster CircuitPython LED animation with ulab
- Simple analysis of a circuit for collecting the average value of AC voltage
- EEWORLD University Hall----Live Replay: Infineon / Weikeng - Market environment is uncertain, Infineon is very sure to protect IoT devices
- Usage of pragma in dsp
- FPGA Learning Notes-----FPGA Competition Adventure
- W806 Lighting