First step is to enable a timer. The clock configuration is like this:
First step is to enable the statistics in CubeMX: