Blog is a good notebook to record everything I am afraid of forgetting.
STM8S is inexpensive and of good quality. TIM2 can generate three PWM waveforms at the same time, with the fastest speed reaching 5MHZ
#include "stm8s.h"
uint16_t CCR1_Val = 500;
uint16_t CCR2_Val =
250;
uint16_t CCR3_Val = 100;
static void TIM2_Config(void);
void
main(void)
{CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);//16/1=16MHZ
TIM2_Config();
while (1)
{}
}
static void TIM2_Config(void)
{
TIM2_TimeBaseInit(TIM2_PRESCALER_1, 200);
TIM2_OC1Init(TIM2_OCMODE_PWM1,
TIM2_OUTPUTSTATE_ENABLE,CCR1_Val, TIM2_OCPOLARITY_HIGH);
TIM2_OC1PreloadConfig(ENABLE);
TIM2_OC2Init(TIM2_OCMODE_PWM1,
TIM2_OUTPUTSTATE_ENABLE,CCR2_Val, TIM2_OCPOLARITY_HIGH);
TIM2_OC2PreloadConfig(ENABLE);
TIM2_OC3Init(TIM2_OCMODE_PWM1, TIM2_OUTPUTSTATE_ENABLE,CCR3_Val,
TIM2_OCPOLARITY_HIGH);
TIM2_OC3PreloadConfig(ENABLE);
TIM2_ARRPreloadConfig(ENABLE);
TIM2_Cmd(ENABLE);
}
#ifdef USE_FULL_ASSERT
void assert_failed(uint8_t* file, uint32_t line)
{
while (1)
{
}
}
#endif
Previous article:STM8S power consumption summary
Next article:STM8S power management - focus on active stop mode
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- 【ST NUCLEO-H743ZI Review】(4) First experience with MQTT in IoT
- TM4C serial port transmission failed
- TI buck-boost supercapacitor charging solution
- EMCV transplantation problem, first time using DSP, don't quite understand
- FPGA controls the DSP power-on reset procedure.
- EEWORLD University ---- Ultra-low power wireless MCU platform CC1310DK based on SimpleLink
- Cute color-changing LED headdress
- 4. Microcontroller peripheral circuit modules used in previous "control" competitions
- Radar Principle
- Lonely thoughts