STM32汇编精确延时函数(调试)
/*SYS:72M*/
__asm void Delay_ms(R0)
{
PUSH {R1} //2个周期
DELAY_NMSLOOP
SUB R0,#1 //R0=R0-1
MOV R1,#7199
DELAY_ONEUS
SUB R1,#1
NOP
NOP
NOP
NOP
NOP
CMP R1,#0
BNE DELAY_ONEUS
CMP R0,#0
BNE DELAY_NMSLOOP
POP {R1}
BX LR //子程序返回
}
int main(void)
{
RCC_Configuration();
GPIO_Configuration();
while(1)
{
GPIO_SetBits(GPIOD,GPIO_Pin_3);
Delay_ms(1000);
GPIO_ResetBits(GPIOD,GPIO_Pin_3);
Delay_ms(1000);
}
}
评论