Using STM8S internal clock to generate PWM (TIM2)

Publisher:数字探险家Latest update time:2020-07-14 Source: elecfansKeywords:STM8S Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

  1 Description

  Use STM8S internal clock (HSI);


  PWM mode 2;

  The duty cycle is 50% and the frequency is 2Hz (convenient for testing LED lights);

  PD2 port is connected to an external LED light, and PD2 port outputs PWM wave;

  System clock initialization is very important: CLK_CKDIVR |= 0x08;


  2 Code
Using STM8S internal clock to generate PWM (TIM2)
Using STM8S internal clock to generate PWM (TIM2)

Keywords:STM8S Reference address:Using STM8S internal clock to generate PWM (TIM2)

Previous article:Solutions to common errors in STM8S programs
Next article:【Blue Bridge Cup MCU Group】 (1) Preliminary preparation

Recommended ReadingLatest update time:2024-11-16 11:27

51 MCU outputs 3-way PWM to drive RGB LED source program
Use the microcontroller interrupt to process PWM, control the ordinary three-color LED, output seven different colors, and change with breathing. It does not take up the program running time.    The microcontroller source program is as follows:                          }                                         else
[Microcontroller]
51 MCU outputs 3-way PWM to drive RGB LED source program
Single chip mobile phone battery charger program (PWM automatic voltage regulation)
#include stc12c2052ad.h #include intrins.h #define uchar unsigned char #define uint unsigned int #define AD_SPEED 0x60 //0110,0000 1 1 270 clock cycles to convert once,  //Shaozhanyu production Hebei Zhengding welcomes you Changsha Aviation Vocational and Technical College 2010 QQ: 411656434  // sbit M=P1^5; //Overv
[Microcontroller]
stm32f407 PWM (operation register)
The PWM mode can generate a signal with a frequency determined by the value of the TIMx_ARR register and a duty cycle determined by the value of the TIMx_CCRx register. The PWM mode can generate a signal with a frequency determined by the value of the TIMx_ARR register and a duty cycle determined by the value of the
[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
Share two methods of STC15 timer simulating PWM
I just searched and found that there is no post analyzing PWM in this way in the forum, so I posted one. Flashlight LED control or motor speed control cannot do without PWM. Here are two methods to simulate PWM. If it is not correct, I hope you can give me some advice.     //Use timer loading to simulate PWM. This m
[Microcontroller]
Share two methods of STC15 timer simulating PWM
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
stm32f4, pwm control motor own doubts
This is a schematic diagram of a PWM. PWM is actually a timer that counts itself and compares it with the value we set, and finally gets the high and low levels, thus generating a regular waveform. ARR is the maximum value of the count, and CCRX is the comparison value we set ourselves. The timer pwm has up and down
[Microcontroller]
FTM's PWM, input capture, and quadrature decoding
FTM is a magical module, it can output PWM, input capture, output comparison and orthogonal decoding. The full name of the English is FlexTimer Module, you can understand it as advanced timer module, easy-to-use timer module, etc. FTM is a commonly used module not only in Kinetis 32-bit processors, but also in Freescal
[Microcontroller]
FTM's PWM, input capture, and quadrature decoding
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号