Skip to main content
DAlvarez
Associate II
July 30, 2021
Solved

How to generate 2 sync square signals with timers

I would appreciate if someone could provide me with some tips about how to accomplish this in an optimal way.

I want to generate a square signal in one pin, and exactly the double in other, both must be synchronized.

My first approach was to use one timer with 2 outputs in output compare and "toggle on mach" but both signals have the same frequency, and I only can change the phase with the "pulse" register

As this timers have 4 channels I was thinking in using 1 channel to generate a base signal, and the other channels to toggle the output pin each n number of counts, but I don't know how to do that.

BTW this is a generic question about timers, but I'm working with a Nucleo F722, using CubeIDE 1.7.0 and the HAL libraries.

This topic has been closed for replies.
TDK
TDKBest answer
July 30, 2021

You can do this by setting one channel with 50% PWM and the other channel with toggle on match. I've done it.

Print out relevant TIM registers if this isn't working for you.

"If you feel a post has answered your question, please click ""Accept as Solution""."

2 replies

TDK
TDKBest answer
July 30, 2021

You can do this by setting one channel with 50% PWM and the other channel with toggle on match. I've done it.

Print out relevant TIM registers if this isn't working for you.

"If you feel a post has answered your question, please click ""Accept as Solution""."
DAlvarez
DAlvarezAuthor
Associate II
August 2, 2021

Done it, and works for me. Thanks!