cancel
Showing results for 
Search instead for 
Did you mean: 

Why Does Timer Pin Stay High After Disable?

Rogers.Gary
Senior II
Posted on January 30, 2015 at 00:19

I'm setting up a PWM1 timer output on PC6. It configures and operates OK. However, at the end of the duration I run it for, I disable it, either by direct register, or the function call:

TIM_Cmd(TIM3, DISABLE);  

However, the output pin insists on staying high. Even if I do this:

GPIOC->BSRRL = GPIO_Pin_6;

it still remains high. No matter how I configure it: PU, PD, or NoPUPD.

What's going on? How do i get this pin to stay low? I can run another channel and it behaves just fine, and stays low after running the timer disable function.

thanks...

#stm32f4-timer-output
5 REPLIES 5
Rogers.Gary
Senior II
Posted on January 30, 2015 at 01:13

I managed to figure it out (not) I changed the polarity from high to low. But this doesn't make sense because the other timer's AF channel works with polarity high.

The mysteries of the STM32F4 keep me entertained....

Posted on January 30, 2015 at 09:11

TIMx_CR1.CEN does not influence the outputs, it only gates the clock into the counting element. The output simply stays in its last state - it must behave in the same way for other channels/timers too.

JW

Rogers.Gary
Senior II
Posted on January 31, 2015 at 00:16

This timer output is still giving me grief...

I've tried configuring the pin pulled up, pulled down, and neither.

Attached is a scope shot to see what it appears like. The yellow trace is PC6 (timer 3), the green is PD (timer 4)

No matter what I do with PC6, it wants to transition high at the last cycle.

Here's some code:

/* Output Compare PWM1 Mode configuration: Channel 1 */

TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;

TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;

TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;

//create pulse width for both channels the same

uint16_t onTime = (uint16_t) (timerPeriod * dutyCycle);

TIM_OCInitStructure.TIM_Pulse = onTime;

TIM_OC1Init(TIM3, &TIM_OCInitStructure);

TIM_OC1Init(TIM4, &TIM_OCInitStructure);

At the end of the number of counts (12) it matters not what I do: I can directly write the timer registers or use the timer disable function.

This: TIM_Cmd(TIM3, DISABLE);

or this:

TIM3->CNT = 0;

TIM3->CCR1 = 0;

TIM3->CCR2 = 0;

How can I get this to stay low neatly as PD12 is doing?

In fact, why does that output look like it's slewing so badly? I realize that PD12 is feeding the LED and pullup on the Discovery board, but I also tried physically connecting PC6 to a pullup resistor to Vcc, and it makes no difference.

Help....please....

________________

Attachments :

20150130_154651.jpg : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HzYY&d=%2Fa%2F0X0000000bNY%2FgcggVnUvNu3tjP9dH0DzQFDbuyLUcGWXhc.wDDLXoY8&asPdf=false
Posted on February 02, 2015 at 12:51

> How can I get this to stay low neatly as PD12 is doing?

Post how do you set up both timers. Can you spot the differences?

> In fact, why does that output look like it's slewing so badly? 

Because you set the input on your scope to AC...

JW
Rogers.Gary
Senior II
Posted on February 03, 2015 at 02:10

thank you jw,

I discovered that (scope on AC) before your post (I had meant to reply earlier), also found the issue with interrupt handler and PWM generation on 2 channels works well now.