⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cap_drv.asm

📁 TI的digital motor control lib的源代码。了解TI的编程规范
💻 ASM
字号:
;===========================================================================
; File Name:	Cap_drv.asm			
;
; Module Name: 	CAP_EVENT_DRV	
;
; Initialization Routine: CAP_EVENT_DRV_INIT
;
; Originator:	Digital Control Systems Group
;			Texas Instruments
;
; Description:	Provides the instantaneous value of the selected time 
; 		base(GP Timer) captured on the occurrence of an event. 
;		Such events can be any specified transition of a signal 
;		applied at the capture input pins of 24x/24xx devices.
; 
;				|~~~~~~~~~~~~~~~|
;	CAPn (EV H/W pin) o---->|		|----->o  FIFOn
;				|CAP_EVENT_DRV 	|
;				|		|
;				|---------------|
;
;
; Target dependency:	x240/243/2407
; To Select the target device and CAPn inputs see x24x_app.h file.
;
;
;=====================================================================================
; History:
;-------------------------------------------------------------------------------------
; 9-15-2000	Release	Rev 1.0
;===========================================================================
;(To use this Module, copy this section to main system file)
;		.ref	CAP_EVENT_DRV, CAP_EVENT_DRV_INIT	;function call
;		.ref	CAP_EVENT_DRV_CLKPS_INIT		;function call
;		.ref	CLK_prescaler_bits			;Parameter					
;===========================================================================
;Module definitions for external reference.
		.def	CAP_EVENT_DRV, CAP_EVENT_DRV_INIT	;function call
		.def	CAP_EVENT_DRV_CLKPS_INIT		;function call
		.def	CLK_prescaler_bits			;Parameter	
;===========================================================================
		
		.include	x24x_app.h
		.bss	CLK_prescaler_bits, 1

;Select Capture inputs
CAP1		.set	1
CAP2		.set	0
CAP3		.set	0
CAP4		.set	0

;===========================================================================
CAP_EVENT_DRV_INIT:
;===========================================================================		
;---target dependancy---------------

		POINT_PF2

		.if (x240)
;Select CAP functions for the I/O pins on x240
		.if (CAP4)
		LACC	OCRB
		OR	#00010000000b		;Set pin function as CAP4.
		SACL	OCRB	
		.endif
		
		.if (CAP3)
		LACC	OCRB
		OR	#01000000b		;Set pin function as CAP3.
		SACL	OCRB
		.endif

		.if (CAP2)
		LACC	OCRB
		OR	#00100000b		;Set pin function as CAP2.
		SACL	OCRB
		.endif

		.if (CAP1)		
		LACC	OCRB
		OR	#00010000b		;Set pin function as CAP1.
		SACL	OCRB	
		.endif
		.endif
;------------------------------------------------------------------------
		.if (x243)
;Select CAP functions for the I/O pins on x243
		.if (CAP3)
		LACC	OCRA
		OR	#00100000b
		SACL	OCRA			;Set pin function as CAP3.	
		.endif

		.if (CAP2)
		LACC	OCRA
		OR	#00010000b
		SACL	OCRA			;Set pin function as CAP2.	
		.endif

		.if (CAP1)
		LACC	OCRA
		OR	#00001000b
		SACL	OCRA			;Set pin function as CAP1.	
		.endif
		.endif
;-------------------------------------------------------------------------
		.if (x2407)
;Select CAP functions for the I/O pins on x2407
		.if (CAP3)
		LACC	MCRA
		OR	#00100000b
		SACL	MCRA			;Set pin function as CAP3.
		.endif

		.if (CAP2)
		LACC	MCRA
		OR	#00010000b
		SACL	MCRA			;Set pin function as CAP2.
		.endif

		.if (CAP1)
		LACC	MCRA
		OR	#0001000b
		SACL	MCRA			;Set pin function as CAP1.
		.endif
		.endif				
;----------------------------------------------------------------------------

;---target dependancy--------------------------------------------------------
		.if (x240 | x243)

;Use Timer T2 as time base with default clock prescaler
		POINT_B0
		SPLK	#2, CLK_prescaler_bits	;Default prescaler set to x/4
		CLRC	SXM
		LACC	CLK_prescaler_bits,8
		AND	#0700h
;			 5432109876543210
;			 ||||!!!!||||!!!!
		OR	#1001000001000010b		
		POINT_EV
		SACL	T2CON 			;Cont Up mode
		
		SPLK	#0FFFFh, T2PER		

; Configure Capture registers. [options: Enable CAP1, CAP2, CAP3, CAP4 func]

		.if (CAP1 | CAP2)
;			 5432109876543210
;			 ||||!!!!||||!!!!
		SPLK	#1010000001010000b,CAPCON ;CAP1/2 En, TMR2, +ve edge
		.endif

		.if (CAP3)
;			 5432109876543210
;			 ||||!!!!||||!!!!
		SPLK	#1001000000000100b,CAPCON ;CAP3 En, TMR2, +ve edge
		.endif

		.if (CAP4)
;			 5432109876543210
;			 ||||!!!!||||!!!!
		SPLK	#1000100000000001b,CAPCON ;CAP4 En, TMR2, +ve edge
		.endif
		.endif
;----------------------------------------------------------------------------

;---target dependancy--------------------------------------------------------
		.if (x2407)

;Use Timer T2 as time base with default clock prescaler
		POINT_B0
		SPLK	#2, CLK_prescaler_bits	;Default prescaler set to x/4
		CLRC	SXM
		LACC	CLK_prescaler_bits,8
		AND	#0700h
;			 5432109876543210
;			 ||||!!!!||||!!!!
		OR	#1001000001000010b		
		POINT_EV
		SACL	T2CON 			;Cont Up mode
		
		SPLK	#0FFFFh, T2PER		

; Configure Capture registers. [options: Enable CAP1, CAP2, CAP3]

;Select one of following options
		.if (CAP1 | CAP2)
;			 5432109876543210
;			 ||||!!!!||||!!!!
		SPLK	#1010000001010000b,CAPCONA ;CAP1/2 En, TMR2, +ve edge
		.endif

		.if (CAP3)
;			 5432109876543210
;			 ||||!!!!||||!!!!
		SPLK	#1001000000000100b,CAPCONA ;CAP3 En, TMR2, +ve edge
		.endif
		.endif
		
		RET
;============================================================================
CAP_EVENT_DRV_CLKPS_INIT:
;============================================================================
;---target dependancy--------------------------------------------------------
		.if (x240 | x243)

;Use Timer T2 as time base with selectable clock prescaler 
		POINT_B0
		CLRC	SXM
		LACC	CLK_prescaler_bits,8	;Input user selected prescaler
		AND	#0700h
;			 5432109876543210
;			 ||||!!!!||||!!!!
		OR	#1001000001000010b		
		POINT_EV
		SACL	T2CON 			;Cont Up mode
		.endif

;---target dependancy--------------------------------------------------------
		.if (x2407)

;Use Timer T2 as time base with selectable clock prescaler
		POINT_B0
		CLRC	SXM
		LACC	CLK_prescaler_bits,8	;Input user selected prescaler
		AND	#0700h
;			 5432109876543210
;			 ||||!!!!||||!!!!
		OR	#1001000001000010b		
		POINT_EV
		SACL	T2CON 			;Cont Up mode
		.endif

		RET
;===========================================================================
CAP_EVENT_DRV
;===========================================================================
;No S/W functions are performed here. Capture module performs internal 
;H/W functions as specified in the initialization routines.

		RET

⌨️ 快捷键说明

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