cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 hrtimer example(s)

dejan
Associate II

Are there some working hrtimer examples for STM32H7 floating around?

1 ACCEPTED SOLUTION

Accepted Solutions
Mikhail Z
Senior II

There are a couple in the CubeH7 distribution.

View solution in original post

20 REPLIES 20
Mikhail Z
Senior II

There are a couple in the CubeH7 distribution.

dejan
Associate II

OK, I have found these and played around a bit and find an interesting discovery. According to the data sheet STM32H7 HRTIM clock is Sysclk (480MHz). However, there are reserved settings of clock prescaler in HRTIM_TIMXCR registers, which actually multiply HRTIM clk up to 6.4GHz ! I have tried it and it seems to be working. Perhaps there are some settings/modes where it does not work, so they cut it out from the datasheet?

Mikhail Z
Senior II

How did you verify that the timer really works with 6.4GHz clock?

dejan
Associate II

I programed it to generate squarewave with complementary outputs and deadtime and simply varied value of prescaler parameter while observing outputs with an oscilloscope.

Prescaler effectively divides the clock rate. Did you try anything with prescaler=0?

dejan
Associate II

According to the datasheet, prescaler values below 5 (101) are reserved, but actually MULTIPLY hrtim clk by 2, 4, 8...

Ok. So what was the highest frequency you were able to generate (as seen on the scope)?

dejan
Associate II

My scope goes up to 100MHz, so I can only see squarewaves up to ~30MHz. However, time resolution matches 6.4GHz clock - that is, if I program prescaler to 0 and period register to 3200, I can see 2MHz output signal. Then I programmed the other channel with period of 3201 and now these two channels are not in-sync anymore, since second channel period is longer for 156pS.

dejan
Associate II

Actually, it's even better - I just realized that HRTIMSEL bit in CFGR was reset, so HRTIM was supplied with 200MHz clock. Now I set it to 1 (HRTIM base clock is now 400Mhz) and thing still works - calculated clock is now 12.8GHz !!!