cancel
Showing results for 
Search instead for 
Did you mean: 

Timer pin output starts HI, after 1st pulsing, is LOW as supposed - why?

SKled.1
Senior II

Hello,

I configured TIM2CH4 on my Nucleo STM32F303RE board to PWM with the LL library, and added some extra code to actually enable the outputs, set compare to with 50:50 duty, enabled the UPDATE IRQ and implemented the ISR to count down from a value initialized to a wanted number of pulses, and if it is 0, I call LL_TIM_DisableIT_UPDATE and LL_TIM_DisableCounter, which in turn I enable in my "start pulses" routine.

Also, I configured the "CH Polarity" in Pinout & Configuration tab to LOW.

So far so good, the scope output, starting with the second run of the routine, looks exactly like I want: The idle signal is low, when I start the pulsing, I see e.g. 10 pulses, and the pin ends on an idle low level.

The problem is that the whole thing starts with the output pin being HI after "booting".

Only after the first pulsing it remains low.

I tried, in main.c in the generated TIM2 init routine, user code section, to add enabling the output already (as opposed to my later init routines), with TIM2->CCER |= TIM_CCER_CC4E.

But that didn't help.

How can I make the system start with a low idling pin before doing the first pulses?

(for now I'll just put in a hack of doing one pulse before configuring the connected device that acts on those pulses, but it's, well, a hack ;) )

Edit: Added requested images

Register contents - if you'd like any of those dissected by bits I can screencap that, too.

(hope this becomes bigger in the real post, in the editor this is shrunk a lot, and I see no way to change that)

0693W000001qPM5QAM.png

This is that it looks like after booting - note the yellow line starting at a high level.

Then 10 pulses are made, well, 9.5 in this case, as the 1st one is missing the rising edge.

(ignore the cyan signal, it's just a pin toggling back and forth once per run)

0693W000001qPLlQAM.png

This is what it's supposed to look like: The line starts LOW, and therefore produces 10 instead of 9 rising edges.

0693W000001qPLWQA2.png

10 REPLIES 10

>> The thing is that the graphical depiction of assigned pins, and clock tree with bounds checks and all, is very useful.

>>

> Sure, I can't even imagine how could I handle the pinout of a 176 pin package without it.

Paper and pencil (and highlighters) . Call me old fashioned.

And I *did* try MicroXplorer, back then; was not impressed. (But I found there's synergetic effect when using both, clicky part handled by my colleague).

Spreadsheet lately, converting the respective model's xml from CubeMX/mcu, to csv.

JW