stm8 clock

Publisher:科技小巨人Latest update time:2017-02-04 Source: eefocusKeywords:stm8  clock Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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:


  1. void main(void)  

  2. {  

  3.     GPIO_Init(GPIOC, GPIO_Pin_4, GPIO_Mode_Out_PP_High_Fast);  

  4.   

  5.     //CLK_CCOConfig(CLK_CCOSource_HSI, CLK_CCODiv_1); /* 16MHz */  

  6.     CLK_CCOConfig(CLK_CCOSource_HSI, CLK_CCODiv_16); /* 1MHz */  

  7.   

  8.     while (1);  

  9. }  

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:


  1. void main(void)  

  2. {  

  3.     uint32_t freq = CLK_GetClockFreq();  

  4.     while (1);  

  5. }  

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:


  1. void main(void)  

  2. {  

  3.     uint32_t freq;  

  4.   

  5.     freq = CLK_GetClockFreq();  

  6.     while (1);  

  7. }  

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.


Keywords:stm8  clock Reference address:stm8 clock

Previous article:The difference between CY and OV microcontrollers
Next article:stm8 rtc clock

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

Detailed explanation of the internal clock circuit of MCS-51 single chip microcomputer
There is a high-gain inverting amplifier inside the MCS-51 microcontroller chip, whose input is the chip pin XTAL1 and whose output is the pin XTAL2. Outside the chip, a crystal oscillator and a fine-tuning capacitor are connected across XTAL1 and XTAL2 to form a stable self-excited oscillator, which is the clock circ
[Microcontroller]
Detailed explanation of the internal clock circuit of MCS-51 single chip microcomputer
STM8 HSI clock correction register
STM8 HSI clock correction register (CLK_HSITRIMR) Address offset value: 0x0C Reset value: undefined Position 7:4 Reserved. Always 0. Bit 3:0 HSITRIM : HSI trim value written by software to fine-tune the HSI calibration value Note: On high-density products, only bits 2:0 are available. On medium-density or small-de
[Microcontroller]
STM8 HSI clock correction register
STM8 MCU Engineer's Path III - The Difference Between .C and .H Header Files
I am a fool who is learning MCU. Today I finally understand a little bit of programming ideas. I understand some things I didn't know before. I want to record my journey to become a MCU engineer. It is only suitable for beginners. First of all, I am the dumbest rookie in the world. The following is just my own under
[Microcontroller]
STM32 clock system
As we all know, the clock system is the pulse of the CPU, just like a person's heartbeat. So the importance of the clock system is self-evident. The clock system of STM32 is relatively complex, unlike the simple 51 microcontroller where one system clock can solve everything. So some people ask, isn't it simple to use
[Microcontroller]
STM32 clock system
About the failure of using IAR software stlink to download stm8 program
I used to use IAR normally, but this time I used stlink to download, and stlink could not download for unknown reasons. I turned off the power and restarted it. Sometimes it worked, but sometimes it really did not work. The prompt message was as shown in the figure below. Failed to initialize communcation with hardw
[Microcontroller]
About the failure of using IAR software stlink to download stm8 program
s3c2440 bare board_clock system and timer
If Fout = 200MHz, then Fout = 2 *m * Fin / (p * 2 ^ s) = 2 * (92 + 8) * 12MHz / (3 * 2 ^ 2) = 200MHz m = 100, MDIV = 92 p = 3,     PDIV = 2 s = 2, SDIV = 2 #define S3C2440_MPLL_200MHZ     ((0x5c 12) | (0x01 4) | (0x02)) CLKDIVN  = 0x03;            // FCLK:HCLK:PCLK=4:2:1, HDIVN=1,PDIVN=1 /* * * * *
[Microcontroller]
s3c2440 bare board_clock system and timer
vfd with stm8
I wrote a driver for pt6311 before. To make a clock, I considered using stm8 as the master control, so I ported the previous driver to stm8. By the way, I became familiar with the operation of stm8 2333. Source code:  1 #ifndef PT6311_H  2 #define PT6311_H  3   4 #include "stm8s.h"  5 #include "delay.h"  6 #incl
[Microcontroller]
MC9S12G clock configuration
1. Enable external clock: Set the OSCE bit of the CPMUOSC register to 1 2. Calculate the required frequency (taking 24Mhz as an example): PLLCLK (24Mhz) = 2 x OSCCLK (oscillator frequency, i.e. your external crystal) x / 3. After calculating SYNR, REFDV Assign the value of SYNR to the first six bits of CPMUS
[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号