Using TIM5 for function call timing and not getting expected results
STM32F777
__HAL_RCC_TIM5_CLK_ENABLE();
TIM5->PSC = HAL_RCC_GetPCLK1Freq()/1000000 - 1;
TIM5->CR1 = TIM_CR1_CEN;
cyclecountstart = TIM5->CNT;
HAL_Delay(1);
cyclecountend = TIM5->CNT;
cyclecount = cyclecountend - cyclecountstart;I expect to see cyclecount to be somewhere in the neighborhood of 1000. Yes I know it could be as high as 2000. However, I consistently get around 168,000. I have verified prescaler is getting set how I expect (53 since PCLK1 is 54 MHz). If I remove the delay completely I see around 14 counts which I guess is believable but seems high.
What am I missing?
