stm8s003MCU_PWM_pin function configuration

Publisher:乡村乐园Latest update time:2020-02-04 Source: eefocusKeywords:stm8s003  PWM Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

I am currently developing an LED light product using the stm8s003 MCU. I am using the PWM output function of TIM2, using TIM2_CHANNEL3, and the PA3 pin is multiplexed as TIM2_CH3.


1. How to reuse the PA3 pin as TIM2_CH3

The pin multiplexing function of stm8MCU is not like the NXP MCU or 51MCU I have used before. The NXP MCU pins used before have dedicated pin function configuration registers, and the pins can be configured to different functions through the configuration registers. The pins of stm8MCU have a main function (after reset), which is the main function of the pin after reset. In addition, the pin has a default alternet function, for example: the default alternet function of PA3 is TIM2_CH3. If you want to use TIM2_CH3, you only need to configure the TIM2_CH3 function when TIMER2 is initialized and enable TIMER2 to use the TIM2_CH3 function.


In the pin description of stm8MCU, you can also see that the pin has an alternet function after remap [option bit]. The function in [ ] refers to the pin function that can be realized by configuring AFR through STVP software.


2. Output status of PWM function pin after stm8 timer stops

After the stm8s timer function stops, the PWM function output of the channel pin corresponding to the timer is in an uncertain state. So if you want to keep the PWM function pin in a certain state after turning off the timer, such as turning off the PWM function and outputting a low level. This requires configuring the CCMR1 register of the timer. As shown below, using the library function, after TIMER2 is turned off, keep the pin output low level:


TIM2_Cmd(DISABLE);  

/* Pull the level to low after stopping PWM */  

TIM2_ForcedOC1Config(TIM2_FORCEDACTION_INACTIVE);

Keywords:stm8s003  PWM Reference address:stm8s003MCU_PWM_pin function configuration

Previous article:STM8 timer TIM1 timing
Next article:Setting the level when stm8 pwm stops

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

10. Learn ARM from scratch - Detailed explanation of pwm based on Exynos4412
1. What is PWM PWM, the English name Pulse Width Modulation, is the abbreviation of pulse width modulation. It modulates the width of a series of pulses to produce the required waveform (including shape and amplitude) and digitally encodes the analog signal level. In other words, the change of signal and energy is adj
[Microcontroller]
10. Learn ARM from scratch - Detailed explanation of pwm based on Exynos4412
【PIC32MZ】PWM breathing light
PWM is similar to a switching power supply, inserting a ground pulse in the middle of a high voltage to reduce the effective voltage. In some voltage-insensitive devices, the voltage reduction effect can be achieved, such as the brightness change of an LED. As mentioned before, Harmony's Dynamic is not perfect yet,
[Microcontroller]
【PIC32MZ】PWM breathing light
51 MCU timer realizes PWM wave
The 51 single-chip microcomputer can realize PWM wave output, and the principle is actually the same. To put it simply, the PWM wave is a signal that makes a certain pin output a periodic and continuous high and low level change. So how to use the 51 single-chip microcomputer to achieve periodic high and low levels?
[Microcontroller]
Tiny210 bare metal PWM controlled buzzer
start.S source code: .global _start _start:     ldr sp, =0xD0030000 // Initialize the stack because the C function will be called later      bl clock_init // Initialize the clock      bl ddr_init // Initialize memory      bl nand_init // Initialize NAND      ldr r0, =0x36000000 // location to be copied to DDR      ldr
[Microcontroller]
LPC1768 PWM Experiment
PWM is pulse width modulation. Pulse width modulation is a very effective technology that uses the digital output of a microprocessor to control analog circuits . It is widely used in many fields from measurement, communication to power control and conversion. Pulse width modulation is an analog control method that m
[Microcontroller]
STM8S003/903 using ADC interrupt function
Regarding the ADC interrupt function of the STM8S003/903 chip (including two cases), record your understanding: 1. When using ADC interrupt for a single channel: If you only need to collect one analog quantity in the project, and want to use interrupt mode to obtain the AD value, then set it as follows: void ADC1_
[Microcontroller]
There is no waveform output when configuring the PWM output of STM32
In the past, when organizing the code, all peripherals, such as ports, timers, serial ports, etc., were initialized when the system clock was initialized. Today I had a sudden idea to put the initialization of each peripheral into the module of each peripheral, so that unused peripherals do not need to be given cloc
[Microcontroller]
STM32 MCU simple timer PWM output
Since APB1 is set to 2 division in RCC->CFGR clock configuration register, TIM3 is its multiplier == 72M You can refer to the STM32 MCU built-in PWM output experiment I published last time:  http://www.51hei.com/mcu/2123.html  . This time, the PWM generated by the timer is used.   //----------------------------
[Microcontroller]
STM32 MCU simple timer PWM output
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号