karpavicius.linas

STM32H7 HRTIM1 support ps resolution timer ? (Answer is complicated)

Discussion created by karpavicius.linas on Sep 23, 2017

Hello, i was working on trying to control HRTIM1 CCR register so i could do 5 phase stepper driver with pure sinus output.

 

I get 400MHz tic frequency, but for some reason i could not control duty cycle.

 

I found interesting line:

 

#define HRTIM_PRESCALERRATIO_MUL32    ((uint32_t)0x00000000U)  /*!< fHRCK: 4.608 GHz - Resolution: 217 ps - Min PWM frequency: 70.3 kHz (fHRTIM=144MHz). */
#define HRTIM_PRESCALERRATIO_MUL16    ((uint32_t)0x00000001U)  /*!< fHRCK: 2.304 GHz - Resolution: 434 ps - Min PWM frequency: 35.1 KHz (fHRTIM=144MHz). */
#define HRTIM_PRESCALERRATIO_MUL8     ((uint32_t)0x00000002U)  /*!< fHRCK: 1.152 GHz - Resolution: 868 ps - Min PWM frequency: 17.6 kHz (fHRTIM=144MHz). */
#define HRTIM_PRESCALERRATIO_MUL4     ((uint32_t)0x00000003U)  /*!< fHRCK: 576 MHz - Resolution: 1.73 ns - Min PWM frequency: 8.8 kHz (fHRTIM=144MHz). */
#define HRTIM_PRESCALERRATIO_MUL2     ((uint32_t)0x00000004U)  /*!< fHRCK: 288 MHz - Resolution: 3.47 ns - Min PWM frequency: 4.4 kHz (fHRTIM=144MHz). */
#define HRTIM_PRESCALERRATIO_DIV1     ((uint32_t)0x00000005U)  /*!< fHRCK: 144 MHz - Resolution: 6.95 ns - Min PWM frequency: 2.2 kHz (fHRTIM=144MHz). */
#define HRTIM_PRESCALERRATIO_DIV2     ((uint32_t)0x00000006U)  /*!< fHRCK: 72 MHz - Resolution: 13.88 ns- Min PWM frequency: 1.1 kHz (fHRTIM=144MHz). */
#define HRTIM_PRESCALERRATIO_DIV4     ((uint32_t)0x00000007U)  /*!< fHRCK: 36 MHz - Resolution: 27.7 ns- Min PWM frequency: 550Hz (fHRTIM=144MHz). */

 

First, i was using DIV1 and CPU clock. It give me 400MHz, no magic.

 

But plugging HRTIM_PRESCALERRATIO_MUL32 increased PWM frequency by 32 (400MHz*32 = 12.8GHz!!!!!)
And yes, with period of 1000, i am getting, surprise surprise 12.8MHz PWM frequency with interesting jitter  of 2.8ns


So what ? Does ST tried to make HRTIM with ps resolution in H7 series, but failed, and kept simple 400MHz counter but at the same time left hardware on silicon for ps resolution ?

Outcomes