Skip to main content
JLadm.1
Visitor II
Jan 22, 2021 3:47 PM UTC
Question

How to set the STM32G474 HRTIM to variable frequency with constant on-time?

Hello

I'm trying to set the HRTIM to generate fixed on-time and variable frequency.

Now I can set the frequency precisely but the duty cycle is somehow held at 50 %.

I have found that similar behavior is expected in so-called "half mode", but the half mode isn't enabled.

I even tried to recover the original compare values, right after setting the period register, but nothing changed.

STM32CUBEMX ioc file and main.c files attached for reference

Thank you very much.

This topic has been closed for replies.

1 reply

Jiri VLCEK
ST Employee
Feb 2, 2021 1:07 PM UTC

Hello,

You can try to use direct register's access:

HRTIM1_TIMA->PERxR = (new_value);

HRTIM1_TIMA->CMP1xR = (new_value);

The change should be visible on pin immediately.

Best Regards,

Jiri