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

📄 dtfmsend.asm

📁 用汇编写的可以根据电阻网络发送软件发送DTMF的程序
💻 ASM
📖 第 1 页 / 共 3 页
字号:
							
_ExectuPressKey1:
	mov	nError,#0x00
	cjne	a,#KEY_OK,_ExectuPressKey2			; is this key OK?	
	jmp	_TheKeyOK							; jamp _OKState
	
_ExectuPressKey2:
	cjne	a,#KEY_RESET,_ExectuPressKey3	; is BackSpace?
	jmp	_TheKeyReset					; jamp _BackSpaceState
			
_ExectuPressKey3:
	cjne	a,#KEY_CLEAR,_ExectuPressKey4		; is Reset?
	jmp	_TheKeyClear						; jamp _ResetState0		
	
_ExectuPressKey4:
	cjne	a,#KEY_ERROR,_ExectuPressKey5		; is no effect key ?
	jmp	_NoEffectKey						; jamp _NoEffectKeyState
	
_ExectuPressKey5:								; the effect key

	jmp	_TheKeyEffect						; jamp _EffectKeyState
	;--------------------------------------------------------------------

;********************************************************************
; State Name     	  	: TheKeyOK
; Description      		: the OK key action, Copy the keyboard temp buffer to keyboard buffer,
;				: thebuffer size is BUF_SIZE,setb b3s                                                      
; Create by        		: Cloud zhou
; Last modified by 		: 
;********************************************************************
_TheKeyOK:
	mov	r0,#BUF_START
	mov	r1,#nBuffferStartTemp
	mov	r3,#BUF_SIZE
	
_TheKeyOK1:							;Copy the nBuffferStartTemp to BUF_START
	mov	a,@r1
	mov	@r0,a
	inc	r1
	inc	r0
	djnz	r3,_TheKeyOK1
	mov	p2,#0x80			; setb p2.7, it meaning the okKey Function finish
	setb	b3s

	ret	
	;----------------------------

;********************************************************************
; State Name     	  	: TheKeyReset
; Description      		: send the last time keyValue 
; Input        			: nKeyANum, b3s                                                        
; Output                        :       
; Effect       			:                                                         
; Create by        		: Cloud zhou
; Last modified by 		: 
;********************************************************************
_TheKeyReset:
	setb	b3s
	mov	nKeyANum,nKeyResetNum
	
_TheKEY_ResetFinish:

	ret
	;----------------------------------------

;********************************************************************
; State Name     	  	: TheKeyClear
; Description     	 	: Clear the keyboard temp buffer
; Input        			: nBufferStartTemp, BUF_SIZE, nKeyResetNum, nKeyANum                                                         
; Output       			: nKeySaveNow = #nBufferStartTemp                            
; Effect       			: p2 = #0x00                                                      
; Create by        		: Cloud zhou
; Last modified by 		: 
;********************************************************************
_TheKeyClear:
	mov	r0,#nBuffferStartTemp
	mov	nKeySaveNow,#nBuffferStartTemp
	mov	r3,#BUF_SIZE
	
_TheKeyClear1:					; Reset the nBuffferStartTemp to BUF_START
	mov	@r0,#0x00
	inc	r0
	djnz	r3,_TheKeyClear1
	mov	p2,#0x00		; Reset finish and clr p2
	mov	nKeyANum,#0x00
	mov	nKeyResetNum,nKeyANum

	ret	
	;--------------------------------------

;********************************************************************
; State Name     	  	: TheKeyEffect
; Description      		: Save the press key to now address in Keyboard buffer,
;				: if nKeySaveNow = #nBufferEndTemp will no action
; Input        			: nFirstKey, nKeySaveNow,nBuffferEndTemp ,nKeyANum,nKeyResetNum                                                        
; Output       			: if nKeySaveNow < #nBufferEndTemp,then nKeySaveNow++,else return void                         
; Effect       			: if nKeySaveNow < #nBufferEndTemp output p2 = nFirstKey, else p2 no action                                                       
; Create by        		: Cloud zhou
; Last modified by 		: 
;********************************************************************
_TheKeyEffect:
	mov	a,nFirstKey
	cjne	a,#KEY_ERROR,_TheKeyEffect1	; is the Error key (it's prerequisite, when keyValue error,it will function)
	jmp	_TheKeyEffectFinish			; have error keyvalue and no action

_TheKeyEffect1:		
	mov	r0,nKeySaveNow
	cjne	r0,#nBuffferEndTemp,_TheKeyEffect2

	jmp	_TheKeyEffectFinish			; the keyboard full and no action

_TheKeyEffect2:
	mov	@r0,nFirstKey
	mov	p2,nFirstKey
	inc	nKeySaveNow
	inc	nKeyANum
	mov	a,nKeyANum
	cjne	a,#0x10,_TheKeyEffectFinish
;	setb	b3s				; keyboard buffer full can send DTMF

_TheKeyEffectFinish:
	mov	nKeyResetNum,nKeyANum
	setb	b3s				; keyboard buffer full can send DTMF

	ret
	;------------------------------------
		
;********************************************************************
; State Name     	  	: _NoEffectKeyState
; Description     	 	:  when press a no efffect key, it will jmp this state
; Create by        		: Cloud zhou
; Last modified by 		: 
;********************************************************************
_NoEffectKey:
	mov	nError,#0xFF
	
	ret
	;---------------------------

;==============================================================================
;==============================================================================
          
;------------------------------------------------------------------------------
; Function Name		: DTMFSend                                              
; Description  		: DTMF coding send program                                                         
; Input        		: DTMFSendValue                                                         
; Output       		: oPort2                           
; Effect       		:                                                           
; Create by        	: Cloud zhou                                                          
; Last modified by	: 
;------------------------------------------------------------------------------ 
DTMFSend:
	mov	DPTR,#DTMFTable
	mov	r0,nDTMFSendValue
;	mov	a,@r0
	mov	a,r0
	rl	a
	rl	a
	mov	nDSAffectAdd,a
	mov	DPTR,#DTMF_Send_Table		; take the send Frequency firs address 
	movc	a,@a+DPTR
	mov	nDTMFHighF_HAdd,a
	mov	nHigh_HAdd,nDTMFHighF_HAdd	; the high frequency of high 8bit address
	inc	DPTR
	mov	a,nDSAffectAdd
	movc	a,@a+DPTR
	mov	nDTMFHighF_LAdd,a
	mov	nHigh_LAdd,nDTMFHighF_LAdd	; the high frequency of low 8bit address
	
	inc	DPTR
	mov	a,nDSAffectAdd
	movc	a,@a+DPTR
	mov	nDTMFLowF_HAdd,a
	mov	nLow_HAdd,nDTMFLowF_HAdd	; the low frequency of high 8bit address
	inc	DPTR
	mov	a,nDSAffectAdd
	movc	a,@a+DPTR
	mov	nDTMFLowF_LAdd,a
	mov	nLow_LAdd,nDTMFLowF_LAdd	; the low frequency of low 8bit address
	setb	tr0
	clr	b80ms
	
_DTMFSend:				; 51us send one data
	jb	b80ms,_DTMFSendEnd	; b80ms flag					; 2us
	mov	DPH,nHigh_HAdd								; 2us
	mov	DPL,nHigh_LAdd								; 2us
	mov	a,#0x01									; 1us
	movc	a,@a+DPTR								; 2us
	cjne	a,#255,_DSHighFNoEnd	; the once high frequency is send finish  	; 2us
	mov	a,#0x00								; 1us		
	movc	a,@a+DPTR							; 2us		
	mov	nHigh_HAdd,nDTMFHighF_HAdd	; the end and,goto head address	; 2us
	mov	nHigh_LAdd,nDTMFHighF_LAdd					; 2us
	jmp	_DSHighFNoEnd1							; 2us
								
_DSHighFNoEnd:
	mov	a,#0x00									; 1us
	movc	a,@a+DPTR								; 2us
	inc	DPTR									; 2us							
	mov	nHigh_HAdd,DPH		; modify address				; 2us
	mov	nHigh_LAdd,DPL								; 2us	
											
_DSHighFNoEnd1:	
	mov	r0,a									; 1us
	mov	DPH,nLow_HAdd								; 2us
	mov	DPL,nLow_LAdd								; 2us
	mov	a,#0x01									; 1us
	movc	a,@a+DPTR								; 2us
	cjne	a,#255,_DSLowFNoEnd	; the once high frequency is send finish  	; 2us
	mov	a,#0x00							; 1us							; 1us
	movc	a,@a+DPTR		; the end and,goto head address ; 2us				; 2us
	mov	nLow_HAdd,nDTMFLowF_HAdd				; 2us
	mov	nLow_LAdd,nDTMFLowF_LAdd				; 2us
	jmp	_DSLowFNoEnd1						; 2us
	
_DSLowFNoEnd:
	mov	a,#0x00									; 1us
	movc	a,@a+DPTR								; 2us
	inc	DPTR			; modify address				; 2us							
	mov	nLow_HAdd,DPH								; 2us
	mov	nLow_LAdd,DPL								; 2us	

_DSLowFNoEnd1:
	clr	cy			; the two data frequency algebraic addition 	; 1us
	add	a,r0									; 1us
	mov	nDTMFMultiF,a								; 1us
	mov	p2,nDTMFMultiF		; output date P2				; 2us
	nop										; 1us	
	jmp	_DTMFSend								; 2us

_DTMFSendEnd:
	inc	r3	
	clr	b80ms
	mov	p2,#0x00
	ret
	;----------------------------------------------------------------------

;------------------------------------------------------------------------------
; Function Name		: DTMFDecoder                                              
; Description  		: DTMF decoding program                                                         
; Input        		: p1.0~p1.5                                                         
; Output       		:                             
; Effect       		:                                                           
; Create by        	: Cloud zhou                                                          
; Last modified by	: 
;------------------------------------------------------------------------------ 
DTMFDecoder:
	mov	ioPort1,#00011111B
	mov	r0,#DTMFSTARTBUF
	mov	DPTR,#DTMFTable		; the DTMF Code table
	
_DTMFDecoder:	
	jnb	ST,$			; if noneffective code, then wait 
	setb	OE			; enable output data
	nop				; need 60ns
	mov	a,ioPort1		; read D0~D3
	anl	a,#0x0f		
	movc	a,@a+DPTR		; catch the DTMF Value
	mov	nDTMFValue,a		; save this code
	cjne	a,#'C',_DTMFDecoderSave		; if DTMF decoder 'C' is the end flag
	jmp	_DTMFDecoderEnd
	
_DTMFDecoderSave:	
	mov	@r0,nDTMFValue
	mov	oPort2,nDTMFValue	; the lED flash
	jb	ST,$			; this effective code is't end?
	clr	OE
	inc	r0

_DTMFDecoderEnd:

	ret
	;---------------------------------

;==============================================================================
;  DTMF Data Table
;==============================================================================
DTMFTable:
	db 'D','1','2','3','4','5','6','7'
	db '8','9','0','*','#','A','B','C'
       ;----------------------------------
       
;==============================================================================
;  DTMF Data Table
 ;==============================================================================
DTMF_Send_Table:      
	dw DTMF_H1633_W,DTMF_L941_W,		DTMF_H1209_W,DTMF_L697_W,	DTMF_H1336_W,DTMF_L697_W
	dw DTMF_H1477_W,DTMF_L697_W,		DTMF_H1209_W,DTMF_L770_W,	DTMF_H1336_W,DTMF_L770_W
	dw DTMF_H1477_W,DTMF_L770_W,		DTMF_H1209_W,DTMF_L852_W,	DTMF_H1336_W,DTMF_L852_W
	dw DTMF_H1477_W,DTMF_L852_W,		DTMF_H1336_W,DTMF_L941_W,	DTMF_H1209_W,DTMF_L941_W
	dw DTMF_H1477_W,DTMF_L941_W,		DTMF_H1633_W,DTMF_L697_W,	DTMF_H1633_W,DTMF_L770_W
	dw DTMF_H1633_W,DTMF_L852_W
       
;==============================================================================
;  DTMF Ware Table (fos=1633*12, T=1/fos)
;==============================================================================
DTMF_H1633_W:
	db 64,96,119,128,119,96,64,32,9,0,9,32,255
DTMF_H1477_W:
	db 64,93,116,127,125,109,83,53,26,6,0,8,28,255
DTMF_H1336_W:
	db 64,91,112,125,127,118,99,73,46,22,6,0,6,22,46,255
DTMF_H1209_W:
	db 64,88,109,123,128,124,111,91,67,42,21,6,0,3,16,35,255
	;==== the low Frequency ware ====
DTMF_L941_W:		
	db 64,83,100,114,124,128,126,119,107,90,72,53,34,19,7,1,0,5,16,31,48,255
DTMF_L852_W:
	db 64,81,97,111,121,127,128,124,116,104,89,73,55,39,24,12,4,0,1,7,17,31,47,255
DTMF_L770_W:		
	db 64,80,94,107,117,124,128,127,123,115,104,90,75,60,44,30,18,8,2,0,2,7,16,28,42,255
DTMF_L697_W:
	db 64,78,92,104,114,122,126,128,127,122,114,104,92,79,65,51,37,25,15,7,2,0,1,6,13,23,35,48,255
	;------------------------------------------------------------------------------------------------
     
;==============================================================================
;==============================================================================
    end

⌨️ 快捷键说明

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