STM32 capture/compare channels

Publisher:LianaiLatest update time:2017-10-29 Source: eefocusKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Each capture/compare channel is built around a capture/compare register (including shadow registers), including the capture input section (digital filtering, multiplexing and prescaler), and the output section (comparator and output control).

Input: Digital filtering, multiplexing and prescaler

Output: Comparator and output control

In capture mode, the capture occurs on the shadow register, which is then copied to the preload register. In compare mode, the contents of the preload register are copied to the shadow register, which is then compared to the counter.

Configuration steps for output compare mode: 

1. Select counter clock (internal, external, prescaler) 

2. Write the corresponding data into the TIMx_ARR and TIMx_CCRx registers 

3. If you want to generate an interrupt request and/or a DMA request, set the CCxIE bit and/or CCxDE bit. 

4. Select the output mode, for example, toggle the OCx output pin when the counter CNT matches CCRx, preload CCRx and unused, turn on the OCx output and high level is valid, then you must set OCxM='011', OCxPE='0', CCxP='0' and CCxE='1'.

 5. Set the CEN bit of the TIMx_CR1 register to start the counter


Keywords:STM32 Reference address:STM32 capture/compare channels

Previous article:Knowledge and configuration of STM32 general timer
Next article:Error[Pe020]: identifier appears when debugging STM32 with IAR

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

STM32 clock frequency and timer clock explanation
******************************** This study note is based on the STM32 firmware library V3.0. Chip model used: STM32F103 Development environment: MDK ********************************* Lesson 1 Clock Frequency     The internal 8M oscillator of STM32F103 can reach a maximum of 72M after frequency multiplication.
[Microcontroller]
STM32 clock frequency and timer clock explanation
FreeRTOS interrupt settings based on STM32 applications
1. Introduction to FreeRTOS interrupt settings Two macros are defined in FreeRTOSConfig.h: configKERNEL_INTERRUPT_PRIORITY configMAX_SYSCALL_INTERRUPT_PRIORITY        ​configKERNEL_INTERRUPT_PRIORITY is used to set the interrupt priority of the RTOS kernel. Because the RTOS kernel interrupt is not allowed to p
[Microcontroller]
FreeRTOS interrupt settings based on STM32 applications
STM32 system timer SysTick
1. SysTick system timer overview After learning about STM32 interrupts, we need to learn about STM32 timers. Just like the most basic function of a phone is to talk to people, the most basic function of a timer is timing (some STM32 timers are more powerful than you can imagine, of course, not SysTick that we are go
[Microcontroller]
STM32 system timer SysTick
Analysis of GPIO_Init() function in STM32
When learning STM32, you must first be familiar with the running light routine. Here we will analyze the GPIO_Init() function in the running light. For example: the port used in the running light example is macLED1_GPIO_PORT=GPIOB,      The controlled pin is GPIO_Pin_0,      The pin mode is GPIO_Mode_Out_PP (general p
[Microcontroller]
Analysis of GPIO_Init() function in STM32
SPI clock of STM32
1) fPCLK is not the CPU frequency, but the frequency of the peripheral bus. 2) The fastest SPI clock of STM32 is 18MHz, which is determined when the chip is designed. 3) STM32's SPI1 is on APB2, SPI2 and SPI3 are on APB1, the highest frequency of APB1 is 36MHz, and the highest frequency of APB2 is 72MHz; therefor
[Microcontroller]
stm32 register address name mapping
Base address + offset address 
[Microcontroller]
The STM32 serial port DMA sends two frames continuously, resulting in partial data overwriting
Problem Description When using the STM32 serial port for DMA transmission (Noraml mode), the transmission function log_printf() is called twice in a task, but the data sent back is not consistent with the expected display on the serial port debugging assistant. Part of the data sent for the first time is overwritten
[Microcontroller]
How to set the timer in STM32
How to set the timer in STM32 The following uses stm32's TIM2 as an example to configure it step by step as a timer: The first Basic configuration of the timer TIM_TimeBaseStructure.TIM_Period = 1000; //Set the automatic load register TIM_TimeBaseStructure.TIM_Prescaler = 35999; //Frequency division count
[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号