delay.c

来自「基于51的单片机的PPP协议实现」· C语言 代码 · 共 88 行

C
88
字号
/******************************************************************************
File Name : Delay.c

Author : Rene Trenado

Location : Motorola Applications Lab, Baja California

Date Created : July 2000

Current Revision : 0.0

Notes : This file contains the code for a variable Delay function 
*******************************************************************************/

#include "delay.h"

BYTE delayCounter;


/***********************************************************************
Function :	Delay

Parameters : 	A Byte containing the number of times __Delay will be
		called

Date : 		July 2000

Desc : 		This function blocks the CPU in multiples of _Delay times	

***********************************************************************/
void Delay (register BYTE times) {
	_Delay();	
}


/***********************************************************************
Assembly Function :	__1msDelay

Parameters : 	None

Date : 		July 2000

Desc : 		This function blocks the CPU in multiples of 1.3mSecs
		delayCount specifies the time base
		__1msDelay = delayCounter x 1.3 mSec

***********************************************************************/
#asm

	xref.b	_delayCounter
	xdef	__Delay

BUSFREQ:	EQU		2

_1msDelay:
		PSHA					;2 cycles
		LDA		#BUSFREQ		;2
DLLoop:	        DBNZA	        DLSub			;3
		BRA		DLDone			;3
DLSub:	        
		MOV		#$FF,_delayCounter 	;4
Here:
		DBNZ	        _delayCounter,Here	;5
		BRA		DLLoop			;3
DLDone:	        PULA					;2
		RTS					;4


/***********************************************************************
Function :	_Delay

Parameters : 	A Byte containing the number of times a base delay will be
		called

Date : 		July 2000

Desc : 		This function blocks the CPU in multiples (Acc value) of 
		delay times

***********************************************************************/

__Delay:        
		JSR   	        _1msDelay
		DBNZA           __Delay
		RTS

#endasm

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?