2023-12-28 09:30 AM
I'm having trouble making the delay function in stm32f411vet. When the power frequency for the chip is 16MHZ, it still works normally but when the frequency is increased to about 64MHZ, the error occurs. Let me all ask you what fault this is.
2023-12-28 11:11 AM
> delay function
Post it.
> when the frequency is increased to about 64MHZ, the error occurs
What error?
JW
2023-12-28 11:25 AM
Present the problem like we're not all psychic. Show code, show issues, explain.
You can't interrupt over a few hundred KHz, and the TIM are all 16-bit so limit the span of time over which they roll-over
For micro-second timing configure the TIM to divide down to 1 MHz, ie Prescaler of 72-1 for 72 MHz or 64-1 for 64 MHz system.
Set Period to 0xFFFF, don't enable the Update Interrupt
TIMx->CNT will count micro-seconds.
uint16_t start = TIMx->CNT;
while((TIMx->CNT- start) < 33); // 33 us delta
2023-12-28 07:26 PM