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

📄 dtfmsend.asm

📁 用汇编写的可以根据电阻网络发送软件发送DTMF的程序
💻 ASM
📖 第 1 页 / 共 3 页
字号:
;******************************************************************************
; File             : DTMFSend.asm
; Date             : October 5,2004 started
; Version          : v1.2 for DTMF coding send
; Author           : Zhou Wuqiang (Cloud zhou) 
; Description      : This is DTMF coding send program 
; Last modified by : 
;******************************************************************************

;******************************************************************************
;  CopyRight (c) 2004-2005, Artech Technology Design Co.,Ltd.
;      ALL RIGHTS RESERVED.                    
;******************************************************************************


;==============================================================================
;  I/O Port Define
;==============================================================================
	; p1.0~p1.3: KeyBoard row control line
	; p1.4~p1.7: Keyboard col control line
 	; p2.0~p2.7: Send the DTMF digit coding Port
        
        ;==>I/O Port
        ioPort1		equ p1
        oPort2		equ p2
        ;----------------------------------------------------------------------
        
;==============================================================================
;  Variable Define 
;==============================================================================
	;==>DTMF value
	nDTMFValue	equ 40h		; the temp Keyboard buffer start address
	
	;==>DTMF Frequency temp save var
	nDTMFHighF_HAdd	equ 41h		; the high Frequency 
	nDTMFHighF_LAdd	equ 42h
	
	nDTMFLowF_HAdd	equ 43h		; the low Frequency
	nDTMFLowF_LAdd	equ 44h
	
	nDTMFMultiF	equ 45h		; the Multi Frequency
	
	nHigh_HAdd	equ 46h
	nHigh_LAdd	equ 47h
	
	nLow_HAdd	equ 48h
	nLow_LAdd	equ 49h

	;==>DTMF send value
	nDTMFSendValue	equ 4ah		; the need Send value
	
	nCount80ms	equ 4bh		; the count 80ms	
	
	nDSAffectAdd	equ 4ch		; the affect DTMF send data
	nDTMFSendNum	equ 4dh		; the nedd send DTMF data's number count
	;==>bit define
	b80ms		bit 00		; the 80ms flag
	;----------------------------------------------------------------------

	;==>keyValue temp save area
	nBuffferStartTemp	equ 60h		; the temp Keyboard buffer start address
	nBuffferEndTemp		equ 70h		; the temp Keyboard buffer end address
	
	;==>bit var 
	bKeyPressFlag		bit 01		; the bKeyPress Flage, when have key will be set
	bKeyPress1SecFlag	bit 02		; wait 1's Flag, when time is lost 1's it will be set 
	bKeyPressFlag10ms	bit 03		; the bKeyPress Flage, when have key will be set, but need 10ms 
	b3s 			bit 04		; the 3s flag
	
	;==>keyValue variable
	nKeyValue		equ	40h		; the press key value
	nFirstKey		equ	41h		; the first scan key value
	nCountTime		equ	42h		; the key press time count
	nKeySaveNow		equ	4fh		; the now save press key value's address
	nKeyBoardState		equ	44h		; the keyboard state it have three state
	nError			equ	45h		; if press a noeffecit it will setb '1',else '0'
	nKeyANum		equ	4dh		; the affect KeyValue number
	nWaitTime 		equ 	4eh		; 3s count
	nKeyResetNum		equ 	7fh		; the save last time send date number
	;----------------------------------------------------------------------

;==============================================================================
;  Constant Define
;==============================================================================
        ;===>Save DTMF code Buffer
        DTMFSTARTBUF	equ 50h		; the start Buffer address
        DTMFENDBUF	equ 60h		; the end Buffer address
        
        ;===>9170's PIN name define 
        DD0	equ	p1.0
        DD1	equ	p1.1
        DD2	equ 	p1.2
        DD3	equ	p1.3
        
        ST	equ	p1.4
        OE	equ	p1.5
        
        ;==>Port2 PIN define
        D3	equ	p2.0		; r = 7.5k
        D2	equ	p2.1		; r = 15k
        D1	equ	p2.2		; r = 30K
        D0	equ	p2.3		; r = 60k
        LED1 	equ	p2.4		; r = 120k
        LED2	equ	p2.5		; r = 240K
        LED3	equ	p2.6		; r = 480K
        LED4	equ	p2.7		; r = 960K
        ;----------------------------------------------------------------------
  
	;===>the key value
		NOKEY			equ		0xff

		;===>effect key value
		KEY_D			equ	0x00		; the key of 'Shift'+'4'
		KEY_1			equ	0x01		; the key of '1'
		KEY_2			equ	0x02		; the key of '2'
		KEY_3			equ	0x03		; the key of '3'
		KEY_4			equ	0x04		; the key of '4'
		KEY_5			equ	0x05		; the key of '5'
		KEY_6			equ	0x06		; the key of '6'
		KEY_7			equ	0x07		; the key of '7'
		KEY_8			equ	0x08		; the key of '8'
		KEY_9			equ	0x09		; the key of '9'
		KEY_0			equ	0x0a		; the key of '0'
		KEY_STAR		equ	0x0b		; the key of '*'
		KEY_WELL		equ	0x0c		; the key of '#'
		KEY_A			equ	0x0d		; the key of 'Shift'+'1'
		KEY_B			equ	0x0e		; the key of 'Shift'+'2'
		KEY_C			equ	0x0f		; the key of 'Shift'+'3'
			
		;===>function key value
		KEY_SHIFT		equ	0x10	; the key of 'Shift' 
		KEY_OK			equ	0x11	; the key of 'Ok'
		KEY_RESET		equ	0x12	; the key of 'BackSpace'
		KEY_CLEAR		equ	0x13	; the key of 'Reset'
			
		;===>no effect key value
		KEY_ERROR		equ	0xee  	; when press key is't effect and function key.
	 						; then the key Value is error(KEY_ERROR)
		;===>system constant area
 	 	BUF_START	equ	0x50				; the effect Keyboard buffer start address buffer
 		BUF_END		equ	0x60				; the effect Keyboard buffer end address buffer
 		BUF_SIZE	equ	0x10				; the effect Keyboard buffer size
 		
		;===>Keyboard three constant state
 		KB_IDLESTATE		equ 0x00		; the idle state of keyboard
 		KB_KEYPRESSSTATE	equ 0x01		; the scan key press state of keyboard
 		KB_FREESTATE		equ 0x02		; the key free state of keyboard
 		;-------------------------------------------------------------------------------	

        
;==============================================================================
;  Macro Define (Enable or Disable Interrupt)
;==============================================================================
	mDI	macro				; Disable Interrupt
		setb	EA			
		endm	mDI
		
	mEI	macro				; Enable Interrupt
		clr		EA			
		endm 	mEI
		;--------------------------------------------------------------			
			
;==============================================================================
;  Vector Area
;==============================================================================

	org	0000h
 	jmp	_Reset

	org	000bh				; timer0 interrupt Vector address
	jmp	_Timer0

	org	0001bh				; timer1 interrupt Vector address
	jmp	_Timer1

;==============================================================================
;  Initial MCU
;==============================================================================

	org		100h

_Reset:
	mDI				; Disable interrupt
	mov	SP,#30h		
	call	Inti_8051			
	call	Inti_Port
	call	Inti_Time
	call	Inti_KeyBoard		; Intial KeyBoard
	mEI				; Enable interrupt
   	mov	ie,#0x8a		; Enable Timer0 interrupt
	mov	nWaitTime,#0x00   	
	mov	nCount80ms,#0x00
	mov	nDTMFSendValue,#nBuffferStartTemp ; modify send dtmf value start address 

	clr	b80ms
	clr	b3s
	setb	tr1
	setb 	tr0
	;-------------------------------------------------
       
;==============================================================================
;  Main Loop
;==============================================================================

_Main:  
	mov	nDTMFSendValue,#0x00

_WaitKey:
;	jnb	bKeyPressFlag10ms,_WaitKey	; wait 10ms, MCU can do other thing
;	jnb     bKeyPressFlag,_WaitKey1		; wait need pressFlag,
						; if a key press it will be set, else MCU can do other thing	
;	clr 	tr0
;	clr	bKeyPressFlag10ms
;	clr	bKeyPressFlag
;	call	GetKey				; get the key value
;	call	KeyTransact			; transact the key value	
;	mov	nWaitTime,#0x00			; clear wait time,(no key press)
;	setb	tr0
	
_WaitKey1:
;	clr	bKeyPressFlag10ms
;	jnb	b3s,_WaitKey		; no key press 3s,or KeyOK, or the keyboard is full this bit will be setb
;	clr	b3s			; 
;	clr	b80ms			; clear 80ms flag
;	clr	tr1			; Time1 stop, (stop the keyboard scan)		mov	nK
;	
;_DSKeyValue:
;	mov	a,nDTMFSendNum		; take the key number, (the keyboard buffer size)
;	cjne	a,#0x00,_DSKeyValueGoOn
;	setb	tr1			; if no key, start Time1, (start the keyboard scan)
;	mov	nDTMFSendValue,#nBuffferStartTemp ; modify send dtmf value start address 
;	mov	nDTMFSendNum,#0x00
;	call	Inti_KeyBoard		; Intial KeyBoard

;	jmp	_Main;
_DSKeyValue:
	mov	a,nDTMFSendValue
	cjne	a,#0x10,_DSKeyValueGoOn
	mov	nDTMFSendValue,#0x00


_DSKeyValueGoOn:
	jnb	b80ms,$		; wait 80ms
	clr	tr0
	call	DTMFSend	; need 80ms

;	call	DTMFDecoder

;	dec	nDTMFSendNum	; send the one value
	inc	nDTMFSendValue	; next DTMF value

	jmp	_DSKeyValue
	;--------------------------
 		                 
;==============================================================================     
;   Interrupt Service Routine       (Timer0)                                            
;==============================================================================     
; Return: Flag
; Descriptor:
; 		1.time0 use mode1 is 16bit timer, per 40ms interrupt once
; 		2.per interrupt inc nCount80ms once 

_Timer0:
		mov	TL0,#0xc0
		mov	TH0,#0x63
		inc	nCount80ms
		mov	a,nCount80ms
		cjne	a,#0x02,_reti
		setb	b80ms			; the 80ms Flag
		mov	nCount80ms,#0x00			
		inc	nWaitTime		
		mov	a,nWaitTime
		cjne	a,#40,_reti		; 3s flag
		setb	b3s
		mov	nWaitTime,#0x00
		
_reti:
		reti		
		;---------------------------

;--------------------------------------------------------------------------------
; Return: KeyValue
; Descriptor:
; 		1.time0 use mode1 is 16bit timer, per 10ms interrupt once
; 		2.per interrupt scan Keyboard once 

_Timer1:
		mov	TL1,#0xf0
		mov	TH1,#0xd8
		mov	p1,#0x0f
		setb	bKeyPressFlag10ms		; the 10ms time Flag
		mov	a,p1			
		cjne	a,#0x0f,_Timer1_1
		jmp	_reti1

_Timer1_1:
		setb	bKeyPressFlag
		
		
_reti1:
		reti		
		;---------------------------

;------------------------------------------------------------------------------
; Function Name		: Inti_8051                                              
; Description  		: intializtion MCU registers                                                         
; Input        		:                                                          
; Output       		:                             
; Effect       		:                                                           
; Create by        	: Cloud zhou                                                          
; Last modified by	: 
;------------------------------------------------------------------------------ 
Inti_8051:
	clr	rs1
	clr	rs0
	mov	r0,#0x40
	mov	a,#0x00

_Inti_8051:

⌨️ 快捷键说明

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