cancel
Showing results for 
Search instead for 
Did you mean: 

How do I generate an Output Compare square wave on TIM8_CH2N using STM32CubeIDE?

arnold_w
Senior II

I'm working with the STM32F407G-DISC1 development board and I would like to generate a square wave on PB14 (TIM8_CH2N). I'm able to successfully toggle PB14 using "bit-banging" and I'm able to successfully generate square waves PC6 (TIM8_CH1) and PC8 (TIM8_CH3). However, no matter what I do, I can't make TIM8 output anything on PB14 (TIM8_CH2N). Does anybody know what I'm doing wrong (please see attached screenshot)? Please note that I can't use any other timer/pin instead.

1 ACCEPTED SOLUTION

Accepted Solutions
arnold_w
Senior II

TIMx_BDT->MOE is being set in HAL_TIM_OC_Start. I solved it like this instead:
HAL_TIM_OC_Start(&htim8, TIM_CHANNEL_2);
TIM8->CCER |= TIM_CCER_CC2NE;

View solution in original post

2 REPLIES 2
Sarra.S
ST Employee

Hello @arnold_w

Try enabling the main output of the timer, which is necessary for advanced-control timers like TIM8

using __HAL_TIM_MOE_ENABLE(&htim8) or by registers BDTR.MOE 

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.

arnold_w
Senior II

TIMx_BDT->MOE is being set in HAL_TIM_OC_Start. I solved it like this instead:
HAL_TIM_OC_Start(&htim8, TIM_CHANNEL_2);
TIM8->CCER |= TIM_CCER_CC2NE;