Skip to main content
Visitor
Nov 8, 2026 3:06 AM UTC
Question

STM32G484 HRTIM comparator bug found (period aliasing)

Hello Nerdz,

I’ve isolated a problem with the HRTIM functions in HRTIM comparators having to do with the specified period being an uneven harmonic of the low resolution timers above it.

If the period is specified as 0x8000, the problem does not happen. If the period is specified as 0xffdf, the problem does happen. I believe this is because 0x8000 is an even power of two, so it perfectly aligns with the 16-bit wrap-around of the lower resolution timers. The internal high resolution counter is16-bits and if this period is not in sync with the start/end of the high resolution period, then comparator errors can happen if the comparison happens within the window at the end of the 16-bit range. (I’m guessing, but this seems likely to me.)

In any case, I’m seeing what appears to be a 5.9ns error that happens some small percentage of the time between two channels on the same timer (CHA in this case using PA8 & PA9 as output pins). They are configured to always be exactly in sync. Once again, if the total high resolution period is 0x8000, there is no error at all. But an 0xFFDF period causes infrequent 5.9ns errors in the outputs. I don’t know if the error is on CH1 or CH2 or if the error is a late trigger or an early one because I’m not going to spend the time to figure that out unless someone volunteers to pay me offensive amounts of money to debug their chips for them.

I have fairly simple code that causes the anomaly and I’m not sure exactly which of 4 comparators is hitting the magic comparison value, but that’s best done via email with an engineer. You have my email address. Tracking it down to which of the four comparitors is hitting which boundary that causes the problem is something STM should do -- not me.

Anyway, cheers. Finding hardware bugs is fun. My guess is this is a silicon limitation that I hope you guys can fix in a future revision. It at least deserves an errata, IMO, once someone at ST figures out exactly why it happens and how to avoid it. Depending on how the failure happens, this could be a real black eye.

(This doesn’t hurt my use case - I’ll just stick to even powers of two for my high resolution period. In my application, that’s close enough.) However, if someone depends on being able to do reliable timing with arbitrary high resolution period counts, this can bite them hard and they might never even notice it until it causes a problem in the field. This is especially true if their application allows the user to set arbitrary values and the problem makes their product wonky but only sometimes. Yuck!

-Sapioplex

1 reply

ST Technical Moderator
Nov 24, 2026 9:08 AM UTC

Hi ​@Sapioplex 

I tested the attached firmware using Timer A outputs TA1 and TA2, with both outputs configured to use the same compare events. The captures show approximately the expected period and 25% duty cycle for both PERIOD = 0x8000 and PERIOD = 0xFFDF. When I compare the two output edges, I measure a difference of approximately 5.6 ns with both period settings. Could you confirm whether this is the behavior you originally reported?

To give better visibility on the answered topics, please click on "Best answer" on the reply which solved your issue or answered your question.Best regards,FBL