Hello @MasterLu, welcome to ST Community, Just to make things more clear for you regarding the ARR and pulse values...This is how the output compare function works; ARR sets the top value of the timer (When the timer's counter reaches this value, it resets to 0), whereas, the pulse value you set for the OC channel is compared with the counter value (when the counter reaches the pulse value, the output pin is toggled) For example, in toggle on match, if counter=pulse, the output is toggled but the counter doesn't reset until it reaches the ARR value. Answer from Sarra.S on community.st.com
Medium
medium.com › @pqshedy33 › what-is-output-compare-mode-on-stm32-timers-1b231988274b
What is output compare mode on STM32 timers? | by Ampheo | Medium
October 9, 2025 - The Output Compare mode is a fundamental feature of STM32’s timer peripherals. Its core function is to compare the current value of the Timer Counter (CNT) register with a pre-loaded value in the Capture/Compare Register (CCR).
EmbeddedExpertIO
blog.embeddedexpert.io
STM32 Timers Applications: Output Compare Mode – EmbeddedExpertIO
This is very useful for applications ... Waves and Clocks) By configuring Output Compare to “Toggle on Match,” STM32 timers can generate clean and stable square waves for use as clocks for other devices, audio signals, or simple waveform generation....
c - STM32 timer output compare interrupt all interrupt flags set at once - Electrical Engineering Stack Exchange
I'm trying to set up the output compare channels of TIM3 of an STM32F103RB MCU. For now I only enabled channel 1, but later I'll need CH2 and CH3 as well. When CH1 triggers, the TIM3->SR registe... More on electronics.stackexchange.com
embedded - Generating waveform using STM32 timer compare - STM32F3Discovery - Stack Overflow
I am attempting to generate a waveform with a period of 33ms. In-between each period, I need to toggle the timer output 5 times with a varying timescale. My initial thought is to do this using a ti... More on stackoverflow.com
STM32 PWM and Output Compare - Electrical Engineering Stack Exchange
In my configuration of the STM32 I have used two synchronized timers, master and slave. The master generates the PWM (channel 1) TRGO update event, and the slave is configured as external clock 1, trigger timer master, output compare no output channel 1. More on electronics.stackexchange.com
timer - TIMx CHx in Output Compare Mode using STM32F4 series and Configuring CubeMx - Stack Overflow
My SYSCLK = 100MHz As I want to generate output pulse for 10 microsec., The timer clock frequency would be = 1/10microsec. = 100KHz or 100,000 Hz. ... Now, I also came across a formula to calculate the ARR value after finding the PSC value. (ref:- Programming STM32 book) More on stackoverflow.com
Videos
18:00
STM32F4 Discovery board - Keil 5 IDE with CubeMX: Tutorial 17 Timers ...
08:04
STM32 General Purpose Timer: Understanding Input Capture IC Mode ...
06:57
STM32 General Purpose Timer: Understanding Output Compare (OC) ...
09:44
6. how to setup stm32 output compare timer - YouTube
07:28
5 . STM32 Tutorial Timer Output Compare - YouTube
Stack Overflow
stackoverflow.com › questions › 78469205 › generating-waveform-using-stm32-timer-compare-stm32f3discovery
embedded - Generating waveform using STM32 timer compare - STM32F3Discovery - Stack Overflow
My thinking is that the DMA is not transferring values from the array to the timer compare register (CRR), some DMA transfer flags are not properly setup or either the CRR has a value of 0 or 33000. Still scratching my head reading the reference manual to find something, will post any update if I can figure this out... new waveform with 6 pulses · timer · embedded · stm32 ·
Top answer 1 of 3
1
I don't use Cube/CubeMX and don't try to understand your code, but IMO you want to do 6 transitions (toggles) per timer period, so you should have: · - 6 values in the table: · · uint16_t wave_buffer[6] = {5700, 3000, 4700, 3000, 10000, 0}; · - trigger DMA *only* from the CCx event, *not* from Update event · JW · PS. Don't start new thread for the same problem
2 of 3
0
Hello @daded.1, · You're on the right track with using HAL_TIM_OC_Start_DMA(), this function allows you to update the CCR with the values provided in the wave_buffer array using DMA and starts the timer in output compare mode. · In the DMA config, the DMA needs to be set to circular mode to reload the wave_buffer values when it reaches the end automatically. · Also, you may want to implement HAL_TIM_OC_DelayElapsedCallback to handle the DMA interrupt on each toggle event · To understand how every function works, you can look at its prototype in the stm32f3xx_hal_tim.c file and read the comments explaining its parameters · Regarding refreshing your memory, refer to the following links: · Description of STM32F3 HAL and low-layer drivers · STM32CubeMX for STM32 configuration and initialization C code generation · · Hope that helps! · To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
STMicroelectronics
st.com › resource › en › application_note › an4013-introduction-to-timers-for-stm32-mcus-stmicroelectronics.pdf pdf
AN4013 Application note - Introduction to timers for STM32 ...
February 1, 2026 - These counters are numbered differently. In the STM32C5 · series, the TIM15, TIM16, and TIM17 counters support up, down, and up/down modes autoreload counter modes. ... Low-power timer and high-resolution timer do not have channels directly comparable with channels on regular timer peripherals.
Medium
medium.com › @csrohit › output-compare-mode-on-stm32f4-timers-6d961162bbe2
Output Compare Mode on STM32F4 Timers | by Rohit Nimkar | Medium
May 15, 2025 - The action taken on a match depends on the OCxM (Output Compare Mode) bits in the CCMRx register: Toggle: The output pin toggles its logic state (high ↔ low). Set/Reset: The output pin is set high or low. PWM: The output pin generates a PWM waveform. ... It monitors the timer counter. When a match occurs, it performs the programmed action on the output pin (see Figure 2 in AN4776). Any STM32F4 board (I’m using an STM32F401, but this works on most STM32F4 MCUs)
STMicroelectronics Community
community.st.com › t5 › stm32-mcus-products › is-it-possible-to-compare-compare-the-output-using-stm32-s-timer › td-p › 80742
Is it possible to compare compare the output using STM32's timer interrupts
February 17, 2022 - I am currently learning to use timer interrupts using the HAL library on the STMF769I-DISCO. I am trying to get the interrupt to activate when it reaches a certain value. From my understanding, the interrupt activates when the counter period overflows. As I'll have different time periods to compare,...
EmbeddedExpertIO
blog.embeddedexpert.io
Working with STM32 and Timers part 6: Output Compare – EmbeddedExpertIO
Posted November 22, 2021 by Husamuldeen ... to the maximum level (set by the ARR), the following will happen: Assigns the corresponding output pin to a programmable value defined by the output compare mode....
STMicroelectronics Community
community.st.com › t5 › stm32-mcus-products › how-do-i-set-a-timer-output-compare-high-or-low › td-p › 696652
Solved: How Do I set a Timer output compare high or low? - STMicroelectronics Community
July 12, 2024 - I am working on a project that uses a PWM on a timer to drive a buzzer. When the buzzer stops I need to set the output compare signal high. The timer set ARR to 250, and the compare value to 125, giving a 4kHz square wave with a 50% duty cycle. I start the timer by enabling it (TIM2->CR1 &= ~TIM_CR1_CEN), and stop the timer by disabling it.
STMicroelectronics
st.com › resource › en › product_training › STM32L4_WDG_TIMERS_GPTIM.pdf pdf
Hello, and welcome to this presentation on the STM32
This slide presents the output compare features.
EmbeddedExpertIO
blog.embeddedexpert.io
Getting Started with STM32F103: Output Compare Mode in Timer – EmbeddedExpertIO
Now, in TIMx capture/compare mode register 1 which is responsible for CH1 and CH2, we need to set OC1M in Toggle on Match Mode as following: ... #include "stm32f1xx.h" int main(void) { RCC->APB2ENR|=RCC_APB2ENR_IOPAEN; /*Configure PA0 as Output Alternate Push/Pull */ GPIOA->CRL|=GPIO_CRL_MODE0; GPIOA->CRL|=(GPIO_CRL_CNF0_1); GPIOA->CRL&=~(GPIO_CRL_CNF0_0); /*Don't remap the pin*/ AFIO->MAPR&=~AFIO_MAPR_TIM2_REMAP; /*Enable clock access to timer2*/ RCC->APB1ENR|=RCC_APB1ENR_TIM2EN; /*Configure timer2*/ TIM2->PSC=8000-1; TIM2->ARR=1000-1; TIM2->CCMR1|=TIM_CCMR1_OC1M_0|TIM_CCMR1_OC1M_1; TIM2->CCER|=TIM_CCER_CC1E; TIM2->CR1|=TIM_CR1_CEN; while(1) { } }
EmbeddedExpertIO
blog.embeddedexpert.io
Getting Started with STM32G0 and STM32CubeIDE: Timer in Output Compare – EmbeddedExpertIO
• Interrupt/DMA generation on ... In STM32 microcontrollers, the Output Compare (OC) mode in the timer peripheral allows you to generate a waveform with a predefined period and pulse width....
Auburn University
eng.auburn.edu › ~nelson › courses › elec3040_3050 › LabLectures › ELEC30x0 Lab7 PWM Slides.pdf pdf
Timer output compare hardware.
Output compare mode – Create a signal waveform/pulse/etc. ... From STM32L100RX Data Sheet Table 7.
Top answer 1 of 3
1
Do you check for the right interrupt flag in the interrupt handler? Also keep in mind that you have to clear the flag right away.
My IRQHandler looks like this, if this is any help for you.
void TIM3_IRQHandler(void) {
if(LL_TIM_IsActiveFlag_CC1(TIM3) == 1) {
LL_TIM_ClearFlag_CC1(TIM3);
TimerCaptureCompare_Callback();
}
}
Edit:
OK as it seems, the HAL_TIM_OC_DelayElapsedCallback interrupt is only fired when the timer overflows (i. e., resets).
This means that you have to enable the overflow interrupt, as the HAL_TIM_OC_Start_IT only enables the capture/compare interrupt.
You only need to enable it before enabling the timer.
__HAL_TIM_ENABLE_IT(&tim3, TIM_IT_UPDATE );
2 of 3
0
Try to replace "TIM_IT_CC1" with "TIM_CHANNEL_1".
MathWorks
mathworks.com › stm32 microcontroller blockset › peripherals › timer peripherals
Timer Capture - Output the capture compare register value - Simulink
Run a Simulink model on STM32 processor. ... The channel port output the capture compare register value of the corresponding selected channel. ... Outputs if overrun occurs during reading the capture compare register. ... To enable this port, select the Output status parameter. ... To enable this port, select the Enable timer counter direction output parameter.