How to realize the interval of 1 second delay function?
Void Delay (uint32_t count)
{
for(; The count!=0; The count -);
}
Delay ();
The above should fill in brackets?
You can answer it for me? Or give me information,
Thank you,
CodePudding user response:
A lot of singlechip routines have ms delay function, 1000 ms is a second,
This is stm32f103 routines,
Delay_ms (300);//delay 300 ms
Void delay_ms (under-16 NMS)
{
U32 temp.
SysTick - & gt; The LOAD=(u32) NMS * fac_ms;//time load (SysTick - & gt; The LOAD of 24 bit)
SysTick - & gt; VAL=0 x00;//to empty counter
SysTick - & gt; CTRL |=SysTick_CTRL_ENABLE_Msk;//to count
Do
{
Temp=SysTick - & gt; CTRL;
}
While (temp& 0 x01 & amp; & ! (temp& (1 & lt; <16)));//wait time
SysTick - & gt; CTRL&=~ SysTick_CTRL_ENABLE_Msk;//off the counter
SysTick - & gt; VAL=0 x00;//to empty counter
}
CodePudding user response: