cancel
Showing results for 
Search instead for 
Did you mean: 

[SOLVED] STM32G030F6 TIM16.1 no output on PB8

ne562
Associate II

I'm trying to get square pulses on PB8 with TIM16.1 output compare, but no pulses on pin (timer seems working: CNT counting, SR flags changing).

Setup code:

gpio_mode(GPIOB,8, GPIO_MO_AF); gpio_af(GPIOB,8, 2); // PB8 as AF2
rcc_apb2_on(RCC_APB2_TIM16);
TIM16->CCMR1 = TIM_CCMR1_OC1M_0 | TIM_CCMR1_OC1M_1; // toggle on match
TIM16->CCER  = TIM_CCER_CC1E;
TIM16->ARR   = TIM16->CCR1 = F_CPU / EADC_MCLK / 2 - 1;
TIM16->CR1   = TIM_CR1_CEN;

Similar code for PA4 and TIM14.1 works as expected:

gpio_mode(GPIOA,4, GPIO_MO_AF); gpio_af(GPIOA,4, 4); // PA4 as AF4
rcc_apb1_on(RCC_APB1_TIM14);
TIM14->CCMR1 = TIM_CCMR1_OC1M_0 | TIM_CCMR1_OC1M_1; // toggle on match
TIM14->CCER  = TIM_CCER_CC1E;
TIM14->ARR   = TIM14->CCR1 = F_CPU / EADC_MCLK / 2 - 1;
TIM14->CR1   = TIM_CR1_CEN;

1 ACCEPTED SOLUTION

Accepted Solutions

TIM16 is one of the timers which has TIMx_BDTR, so TIM16_BDTR.MOE has to be set to enable outputs.

JW

View solution in original post

2 REPLIES 2

TIM16 is one of the timers which has TIMx_BDTR, so TIM16_BDTR.MOE has to be set to enable outputs.

JW

ne562
Associate II

:thumbs_up: thanks, now works...