cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L412 One-pulse Timer not resetting at update event

b.a.
Associate III

Hi all,

I am trying to get a single pulse out of TIM1, triggered by a rising edge on a Pin.

I got it almost working, but the problem is that after the counter reached ARR value, the output channel is reset...

I use PWM mode and the complementary output channel to get the polarity I need.

I could do it with custom IRS, but I quite like the thought to use the dedicated hardware for this task.

In other words, what I want is:

when a rising edge occurs on a pin, the output should go high and stay there for a certain time (CCR), then go low and stay there

The "stay there" part is the one that I don't get working, because on update event the output is reset to low.

Is there any way to change this behaviour and force the output to remain unchanged on update event?

Or another Timer ode that is more suitable for this task?

Cheers,

Bob

11 REPLIES 11
b.a.
Associate III

Hi Jan,

thank you very much for your explanation. I now understand how this works.

Yes, you are right CCRE.CC2E and BDTR.MOE sre set to 1, but at a later time.

I use te CubeIDE to set up timers, maybe not the best idea after all...

But I think you mixed up polarity in the second part:

> CNT increments from 0 to 1. At that moment, comparison with CCR2 comes true, and as CH2 is set to Output Compare and PWM1 in CCMR1, the internal OC2REF signal (result of comparison) goes from active to inactive, [...] output pin would go from 0 to 1

> The prescaler+counter continue counting, up until CNT=0x77F=ARR, and prescaler=0x31. [...] OC2REF goes from active to inactive, thus pin goes from high to low.

Nevertheless I now understand why OC2REF is active during the "idle time" between two triggers. On update event CNT is reset and the comparison result is false again. And this state is maintained until the next compare match occurs.

So the heading for my question is wrong, the output actually resetting is what troubled me 😉

> But I think you mixed up polarity in the second part:

Yes 🙂

> So the heading for my question is wrong, the output actually resetting is what troubled me 😉

Yes, this is confusing.

JW