void SysCtlDelay(unsigned long ulCount)
{
__asm(" subs r0, #1\n"
" bne.n SysCtlDelay\n"
" bx lr");
}
void sys_delay_us(unsigned long us)
{
RCC_ClocksTypeDef RCC_Clocks;
unsigned long cnt = 0;
unsigned long cpu_clk = 0;
RCC_GetClocksFreq(&RCC_Clocks);
cpu_clk = RCC_Clocks.HCLK_Frequency;
cnt = (unsigned long)(us)*(cpu_clk/3000000);
if(cnt<1)
cnt = 1;
SysCtlDelay(cnt);
}
芯片是STM32F103VET6,环境是IAR。
sys_delay_us()函数是微妙延时,但是我看不懂怎么就是微妙延时的呢,那段汇编怎么回事呢?
请高手释疑 |