/************************************
Verify the clock output function of PE0 pin, and use an oscilloscope to view the output 24M clock
After connecting to ST-LINK, in DEBUG mode,
select crystal clock source in Option Bytes EXTCLK
Confirm Flash_Wait_States is set to 1
************************************/
void GPIO_INIT() //PE0 pin CCO output enable, according to the manual, it can be set to pull-up input or push-pull output
{
PE_DDR_DDR0=1;
PE_CR1_C10=1; //PE push-pull output
}
void CLK_INIT()
{
CLK_ECKR_HSEEN=1; //Open external
while(!CLK_ECKR_HSERDY); //Wait for external clock to be ready
CLK_SWCR_SWEN=1; //Enable clock switching
CLK_SWR=0XB4; //HSE is the main clock source
while(!CLK_SWCR_SWIF); //Wait for switching to succeed
CLK_SWCR_SWEN=0; //Clear switching flag
CLK_CKDIVR=0; //No frequency division
}
void CCO_INIT()
{
CLK_CCOR_CCOSEL=2; //Modify it according to the manual and you can see the external clock we want, 24M or 16M 128K, etc.
CLK_CCOR_CCOEN=1; //Enable clock output
}
void main()
{
GPIO_INIT();
CLK_INIT();
CCO_INIT();
while(1);
}
/****************************************************************
I have to mention here that in the iostm8s208r8.h file that comes with IAR for STM8S, the O in OPQ is written as zero in CCOBSY.
If you use it, you must pay attention to it. At least the software I installed has such a problem, although it is not important
************************************************************/
Previous article:The sixth program of STM8S208R8 --- interrupt and navigation key
Next article:The fourth program of STM8S208R8 --- external crystal clock source verification
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- A New Method of Expanding SRAM Externally in MCU
- CircuitPython 6.0.0 Beta 0 released!
- Qorvo Wireless Technology Wi-Fi Father Cees Links Inducted into Wi-Fi NOW Hall of Fame
- October 29 live broadcast review: ST Data Center and Communication Network Power Management Solutions (including video, presentation documents, Q&A)
- What parameters should be considered when evaluating and selecting SiC MOSFET devices?
- Challenge FreeRTOS learning + How to port FreeRTOS and create tasks for STM32F107
- Please analyze this circuit. What will the final waveform be?
- NFC chip selection and basic circuit framework
- 【McQueen Trial】Python Programming (2)
- Application Guide for HB6296 High Voltage and High Current Charging Management Chip for 2-10 Cells Lithium Battery 24V Lead Acid