Question
small and fast: µs-delay with TIMER4
First suggestion after internet inquiry:
// Initialization procedure:
RCC->APB1ENR = 0b00000000000000000000000000000010;
TIM4->PSC = 15;
TIM4->ARR = 65534;
TIM4->CR1 = (1<<0);
// Function:
void delay_US(uint32_t us)
{
uint32_t i;
for( i = 0; i <= us; i++ )
{
/* Clear the count */
TIM4->CNT = 0;
/* Wait UIF to be set */
while((TIM4->SR & TIM_SR_UIF) == 0); /* ?!?!? */
/* Reset UIF */
TIM4->SR &= ~TIM_SR_UIF;
}
}
I need a short common µs-delay - any ideas for the marked µc?
