Hi all! Hope everything is going well. I'm honestly at a loss here, hoping you guys can help. I am returning to a project from a few months ago I was working on and was trying to get some video of it. For example, I have a ultrasonic sensor that I wanted to show working in my video. It wasn't working, and I had no idea why so I did some debugging. Keep in mind this use to work fine for the past year, I don't get what's wrong.
I narrowed it down to what seems to be my microsecond delay function. It would produce a delay that I didn't specify. I tried reconfiguring the clocks so it didn't work, so I opened an older test project and it still is acting up.
Some info
My board is an STM32F746ZG
I'm using TIM3 for the delay function
My code for the delay function
void delay_us(uint16_t us){
__HAL_TIM_SET_COUNTER(&htim3,0); // Set counter to 0
while(__HAL_TIM_GET_COUNTER(&htim3) < us);
}
TIM3 according to the datasheet is connected to APB1. Here is what it's set to

TIM3 itself has a prescalar of 4.5-1, because 4.5Mhz/4.5 = 1Mhz, 1/1Mhz = 1uS for microseconds. The period is 0xFFFF-1.
Below is some example test code
HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_11);
delay_us(10);
Here is the result on the oscillscope. So instead of 10uS, using cursors for measurements (sorry it's not in this photo), it's around 14.7uS instead. Or if I do something like 100uS, I get 94uS instead.

Am I missing something? I don't know if I'm forgetting something since I took a break, or something else. Thanks