2022-06-17 10:30 PM
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;
Solved! Go to Solution.
2022-06-18 02:03 AM
TIM16 is one of the timers which has TIMx_BDTR, so TIM16_BDTR.MOE has to be set to enable outputs.
JW
2022-06-18 02:03 AM
TIM16 is one of the timers which has TIMx_BDTR, so TIM16_BDTR.MOE has to be set to enable outputs.
JW
2022-06-18 02:22 AM
:thumbs_up: thanks, now works...