- 论坛徽章:
- 0
|
#define MSDELAY(msec) (asm_delay(msec * cpu_clk_mhz * 1000));
asm_delay(u32 inst)
{
int temp = (inst) / 10; /* 10 = 2 + 8 , 8 is cortex-A9's branch penalty */
__asm__ __volatile__ (
"1: subs %0, %0, #1 \n"
"bhi 1b"
:
: "r" (tmp)
: "memory"
);
}
/*****************************************************************************/
实际的cpu_clk_mhz = 24 , CPU频率是24MHZ
调用MSDELAY时,MSDELAY(10000),为了延时10s,实际测得的数值为8s。
请教一下,/* 10 = 2 + 8 , 8 is cortex-A9's branch penalty */该如何理解,为什么使用这种方式来实现延时,依据再哪里,望指教。
备注:cortex-A9 is 8-stage pipeline. |
|