Home > other >  Anonymous flight control tick timer microsecond delay don't understand
Anonymous flight control tick timer microsecond delay don't understand

Time:09-26

In time. The c file, here it is not the keil file, want to know about add me QQ2545407140 send you
Stm32f4xx_it. C tick the clock interrupt function, ticking clock related configuration has been configured
Void SysTick_Handler (void)
{
SysTickUptime++;
Sys_time ();
}
Volatile uint32_t sysTickUptime=0;
Uint32_t GetSysTime_us (void)
{
The register uint32_t ms;
U32 value;
Ms=sysTickUptime;
Value=https://bbs.csdn.net/topics/ms * TICK_US + (SysTick -> LOAD - SysTick -> VAL) * TICK_US/SysTick -> LOAD;
The return value.//the LOAD=21 k here, TICK_US=1000, VAL=0, the clock rate=21 m
}
Microsecond delay function
Void Delay_us (uint32_t us)//if you want to delay 10 microseconds us is
{
Uint32_t now=GetSysTime_us ();
While (GetSysTime_us () - now & lt; Us);
}//the subtle delay don't know much about here, didn't enter the interrupt at the beginning, ms=0, value=https://bbs.csdn.net/topics/1000, now in the Delay_us=1000,
While (1000-1000 & lt; 10), is true, always here to wait for, time (LOAD=21 k/21 m, such a terminal is 1 ms, how can come out to microsecond delay?) To enter the interrupt, again after after sysTickUptime++ interrupt, equal to 1, GetSysTime_us () changed, the value of the increased 1000, the condition is false, I quit a while, roughly process is to understand the
 [code]=c 

[/code]
Void Delay_ms (uint32_t ms)//1=1000 ms us
{
While (ms -)
Delay_us (1000);
}
  • Related