Skip to main content
Associate
November 25, 2025
Solved

Generate a single pulse of 12ns with stm32u5

  • November 25, 2025
  • 11 replies
  • 1095 views

Hi there.

I’m trying to generate a 12 ns pulse for a time-of-flight (ToF) application.

I’m using an STM32U5 microcontroller, and I’d like to know whether one of the general-purpose timers (TIM2/TIM3/TIM4/TIM5) can produce a pulse that narrow. With a 160 MHz timer clock, the time resolution is about 6 ns, so in principle it seems feasible, but I may be overlooking something.

Thanks!

Best answer by lucascalam

In the end, I realized I hadn’t been interpreting my results correctly. The pulse shown earlier in IMG_0794 was actually inverted, the relevant pulse was the low portion, not the high one. This means the pulse width was around 200 ticks.

This behavior occurs because, in the selected PWM mode combined with one-pulse mode, the output goes low when the counter transitions from TIMx_CCR to TIMx_ARR. Therefore, for example, if we want a 2-tick low pulse, setting CCR = 198 and ARR = 200 should produce the expected result.

Sorry for the confusion, and thanks to everyone for the support.

Cheers!

11 replies

waclawek.jan
Super User
November 26, 2025

Lesson learned.

Thanks for coming back with the solution.

JW