cancel
Showing results for 
Search instead for 
Did you mean: 

How Do I set a Timer output compare high or low?

JMala.3
Associate III

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. (TIM2->CR1 |= TIM_CR1_CEN).  What I need to do is make sure the output is high when it is disabled.  I tried setting the count value (TIM2->CNT = x) and thought that if I set the count below the 125 threshold, the output would stay low, and if i set the count above the 125 threshold, the count would stay high, However setting the count seems to make no difference to the output compare level.

Anyone have any idea how I can stop the count with the output compare in a defined state?

 

 

 

0 REPLIES 0