- 論壇徽章:
- 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
調(diào)用MSDELAY時,MSDELAY(10000),為了延時10s,實際測得的數(shù)值為8s。
請教一下,/* 10 = 2 + 8 , 8 is cortex-A9's branch penalty */該如何理解,為什么使用這種方式來實現(xiàn)延時,依據(jù)再哪里,望指教。
備注:cortex-A9 is 8-stage pipeline. |
|