I'm trying to use the timer (TIM4) to log rising and falling edge times from an external sensor. I need to set the timer so that it ticks every 1µs and has a period of 40ms (so counts 40, 000 ticks before overflowing). TIM4 has a source clock speed of 84MHz. The datasheet says:
"16-bit programmable prescaler used to divide the counter clock frequency by any factor between 1 and 65536".
However in most tutorials divide by 84 - 1 to obtain 1MHz. Can someone provide the exact formulas to calculate the parameters? Thanks in advance