SPDA_DTMF软拨号

资料大小: 470

所需积分: 0

下载次数:

用户评论: 0条评论,查看

上传日期: 2006-04-18

上 传 者: 发烧友他上传的所有资料

资料介绍

标签:拨号(5)

;=====================================================
; Lixin: 2002/7/30
; dtmf dial
; fx=8M
;=====================================================
.include "sys.h"
.include "def_macro.h"
.include "sys_var.h"
.include "InterruptServer.h"

.global DialOutController_DialOut
.global DialOutController_IniTIal
.global DialOutController_SeTIndex
.global DialOutController_Int_TImerA
.global DialOutController_Int_DA

_sr_DA_OUT  equ  _doc_data
_sr_DTMF_FLAG equ  _doc_flag

bDIAL_INP  equ  0
bFINISH   equ  1

cDIAL_TIME equ 50 ;25   ;0x600*(286/8000000)=54.912ms
cDTSLI_TIME equ 100 ;50  ;(0xc00-0x600)*286/8000000=54.912ms

;DACNT_TBL is the da numbers in one sin wave of a frequency
DACNT_TBL: DW 86,78,71,64,50,45,41,37

;DTRANS_TBL is used to calculate the two freq for one number
DTRANS_TBL: DW 0DH, 00H, 01H, 02H, 04H, 05H, 06H, 08H, 09H, 0AH, 0CH, 0EH, 0BH, 0FH, 03H, 07H; '*'->0AH, '#'->0BH
; the DA out table
;×××××××频率低采样个数多,频率高采样点少××××××××××
F_697:
 DW 0X1C0,0X1E0,0X201,0X221,0X241,0X260,0X27E,0X29B,0X2B7,0X2D1,0X2EA,0X302,0X318,0X32C,0X33E,0X34E,0X35C,0X368,0X371,0X378
 DW 0X37D,0X37F,0X37F,0X37D,0X378,0X371,0X368,0X35C,0X34E,0X33E,0X32C,0X318,0X302,0X2EA,0X2D1,0X2B7,0X29B,0X27E,0X260,0X241
 DW 0X221,0X201,0X1E0,0X1C0,0X19F,0X17E,0X15E,0X13E,0X11F,0X101,0XE4,0XC8,0XAE,0X95,0X7D,0X67,0X53,0X41,0X31,0X23
 DW 0X17,0XE,0X7,0X2,0X0,0X0,0X2,0X7,0XE,0X17,0X23,0X31,0X41,0X53,0X67,0X7D,0X95,0XAE,0XC8,0XE4
 DW 0X101,0X11F,0X13E,0X15E,0X17E,0X19F

F_770:
 DW 0X1C0,0X1E4,0X207,0X22B,0X24D,0X26F,0X290,0X2AF,0X2CD,0X2E9,0X303,0X31B,0X330,0X343,0X354,0X362,0X36E,0X376,0X37C,0X37F
 DW 0X37F,0X37C,0X376,0X36E,0X362,0X354,0X343,0X330,0X31B,0X303,0X2E9,0X2CD,0X2AF,0X290,0X26F,0X24D,0X22B,0X207,0X1E4,0X1C0
 DW 0X19B,0X178,0X154,0X132,0X110,0XEF,0XD0,0XB2,0X96,0X7C,0X64,0X4F,0X3C,0X2B,0X1D,0X11,0X9,0X3,0X0,0X0
 DW 0X3,0X9,0X11,0X1D,0X2B,0X3C,0X4F,0X64,0X7C,0X96,0XB2,0XD0,0XEF,0X110,0X132,0X154,0X178,0X19B

F_852:
 DW 0X1C0,0X1E7,0X20E,0X235,0X25B,0X27F,0X2A2,0X2C4,0X2E3,0X300,0X31A,0X332,0X347,0X358,0X367,0X372,0X37A,0X37F,0X37F,0X37D
 DW 0X377,0X36D,0X360,0X350,0X33D,0X326,0X30D,0X2F2,0X2D3,0X2B3,0X291,0X26D,0X248,0X222,0X1FB,0X1D3,0X1AC,0X184,0X15D,0X137
 DW 0X112,0XEE,0XCC,0XAC,0X8D,0X72,0X59,0X42,0X2F,0X1F,0X12,0X8,0X2,0X0,0X0,0X5,0XD,0X18,0X27,0X38
 DW 0X4D,0X65,0X7F,0X9C,0XBB,0XDD,0X100,0X124,0X14A,0X171,0X198

F_941:
 DW 0X1C0,0X1EB,0X217,0X242,0X26B,0X293,0X2B8,0X2DC,0X2FC,0X31A,0X334,0X34B,0X35D,0X36C,0X377,0X37D,0X380,0X37D,0X377,0X36C
 DW 0X35D,0X34B,0X334,0X31A,0X2FC,0X2DC,0X2B8,0X293,0X26B,0X242,0X217,0X1EB,0X1C0,0X194,0X168,0X13D,0X114,0XEC,0XC7,0XA3
 DW 0X83,0X65,0X4B,0X34,0X22,0X13,0X8,0X2,0X0,0X2,0X8,0X13,0X22,0X34,0X4B,0X65,0X83,0XA3,0XC7,0XEC
 DW 0X114,0X13D,0X168,0X194

F_1209:
 DW 0X240,0X288,0X2CF,0X314,0X355,0X392,0X3CA,0X3FB,0X426,0X449,0X463,0X475,0X47E,0X47E,0X475,0X463,0X449,0X426,0X3FB,0X3CA
 DW 0X392,0X355,0X314,0X2CF,0X288,0X240,0X1F7,0X1B0,0X16B,0X12A,0XED,0XB5,0X84,0X59,0X36,0X1C,0XA,0X1,0X1,0XA
 DW 0X1C,0X36,0X59,0X84,0XB5,0XED,0X12A,0X16B,0X1B0,0X1F7

F_1336:
 DW 0X240,0X290,0X2DE,0X32A,0X371,0X3B2,0X3EC,0X41D,0X445,0X463,0X477,0X47F,0X47C,0X46E,0X456,0X432,0X405,0X3D0,0X392,0X34E
 DW 0X305,0X2B7,0X268,0X217,0X1C8,0X17A,0X131,0XED,0XAF,0X7A,0X4D,0X29,0X11,0X3,0X0,0X8,0X1C,0X3A,0X62,0X93
 DW 0XCD,0X10E,0X155,0X1A1,0X1EF

F_1477:
 DW 0X240,0X297,0X2ED,0X33F,0X38B,0X3CF,0X40A,0X43A,0X45E,0X475,0X47F,0X47C,0X46B,0X44D,0X423,0X3EE,0X3AE,0X366,0X317,0X2C3
 DW 0X26C,0X213,0X1BC,0X168,0X119,0XD1,0X91,0X5C,0X32,0X14,0X3,0X0,0XA,0X21,0X45,0X75,0XB0,0XF4,0X140,0X192
 DW 0X1E8

F_1633:
 DW 0X240,0X2A1,0X2FF,0X358,0X3A9,0X3F0,0X42A,0X456,0X473,0X47F,0X47B,0X466,0X442,0X40F,0X3CE,0X382,0X32D,0X2D1,0X270,0X20F
 DW 0X1AE,0X152,0XFD,0XB1,0X70,0X3D,0X19,0X4,0X0,0XC,0X29,0X55,0X8F,0XD6,0X127,0X180,0X1DE
;FREQ_INDEX is the adresss for the sin data
FREQ_COM_TBL DW F_697,F_770,F_852,F_941,F_1209,F_1336,F_1477,F_1633

TMR16_CON DB 1


; 子程序=>>

DialOutController_Initial:
  ret

DialOutController_SetIndex:
 cp r3,#0bh
 jp UGT,_set_index_fail
 ld _doc_index,r3
 jp _set_index_exit
_set_index_fail:
 ld r3,#0fh
 ld _doc_index,r3 
_set_index_exit:
 ret
  
DialOutController_Int_TimerA:
 LD  R0,_sr_DA_OUT
 BITS ADCON.5   
 LD  DADATA,R0
 LD  DADATA,R0
 LD  DADATA,R0
 LD  DADATA,R0
 BITS _sr_DTMF_FLAG.bFINISH 
 ret
 
DialOutController_Int_DA:
 
 ret
    
;------------拨号程序>>---------------- 
;    PUBLIC _fun_DTMF_DIAL
;**********************************************
;*_FUN_DIAL
;*FUNCTION: DIAL (NUMBER)
;*OUTPUT: DTMF wave
;*HW STACK: USED 1+1=2 LEVEL
;*SW STACK: USED 0 BYTES
;*USED:  NUM_COUNTER,L_FQ_DA_NUM,H_FQ_DA_NUM,LOW_FREQ_I,HIGH_FREQ_I,LOW_F_CNTR,HIGH_F_CNTR,TIMECNTR
;*   IDH,IDL0,ILH,ILL,TBL,TBH,R0,R1,R2,R3_tr_MAC_TMP0[0-1]
;*          FLAG C(Z,NZ)
;**********************************************
;tempdata
STACK_SIZE .SETVAR 0
_tm_LOWFDA_CNT  EQU STACK_SIZE ;DA num in one cycle of  low frequency wave
STACK_SIZE .SETVAR STACK_SIZE+1
_tm_HIGFDA_CNT  EQU STACK_SIZE ;DA num in one cycle of  high frequency wave
STACK_SIZE .SETVAR STACK_SIZE+1
_tm_LOWF_INDEX  EQU STACK_SIZE ;STORE LOW FREQUENCY SIN DATA ADDRESS
STACK_SIZE .SETVAR STACK_SIZE+2
_tm_HIGF_INDEX  EQU STACK_SIZE ;STORE HIGH FREQUENCY SIN DATA ADDRESS
STACK_SIZE .SETVAR STACK_SIZE+2
_tm_LOWF_CNTR  EQU STACK_SIZE ;low freq counter
STACK_SIZE .SETVAR STACK_SIZE+1
_tm_HIGF_CNTR  EQU STACK_SIZE ;high freq counter
STACK_SIZE .SETVAR STACK_SIZE+1
_tm_TIME_CNTR  EQU STACK_SIZE ;counter to control the output time
STACK_SIZE .SETVAR STACK_SIZE+2

bDTMF_FINISH  EQU  bFINISH
;*--------------------------------------------------------------
; Func: _fun_DTMF_DIAL,
; Input: _doc_index, the number to dial out
;*--------------------------------------------------------------

DialOutController_DialOut:
  bitr p4.0
  _macro_ALLOC STACK_SIZE
  
  ld r3,#IS_TIMER_A_DIALOUT
  lcall InterruptServer_Regist
  ld r3,#IS_DA_DIALOUT
  lcall InterruptServer_Regist
  
  ld r3,_doc_index
  cp r3,#0fh
  jp z,_dial_out_exit
  
  BMS
  LD R0, #<DTRANS_TBL ; Transfe from number to position
  LD ILH, R0
  LD R0, #>DTRANS_TBL
  ADD R0, R3
  LD ILL, R0
  LDC @IL
  LD R2, TBL
  LD R3, R2   ; Get the DA count for the frequent combination
  SR R3
  SR R3
  AND R2, #3   ; R2 for high freq, R3 for low freq
  ADD R2, #4
  LD R0, #<DACNT_TBL
  LD ILH, R0
  LD R0, #>DACNT_TBL
  ADD R0, R3
  LD ILL, R0
  LDC @IL
  LD R0, TBL
  _macro_WRITE _tm_LOWFDA_CNT, R0
  LD R0, #>DACNT_TBL
  ADD R0, R2
  LD ILL, R0
  LDC @IL
  LD R0, TBL
  _macro_WRITE _tm_HIGFDA_CNT, R0
  LD R0, #<FREQ_COM_TBL ; Get the freq combination index
  LD ILH, R0
  LD R0, #>FREQ_COM_TBL
  ADD R0, R3
  LD ILL, R0
  LDC @IL
  LD R0, TBH
  _macro_WRITE _tm_LOWF_INDEX, R0
  LD R0, TBL
  _macro_WRITE _tm_LOWF_INDEX+1, R0
  LD R0, #>FREQ_COM_TBL
  ADD R0, R2
  LD ILL, R0
  LDC @IL
  LD R0, TBH
  _macro_WRITE _tm_HIGF_INDEX, R0
  LD R0, TBL
  _macro_WRITE _tm_HIGF_INDEX+1, R0
  LD R0, #0
  _macro_WRITE _tm_LOWF_CNTR, R0
  _macro_WRITE _tm_HIGF_CNTR, R0
  _macro_WRITE _tm_TIME_CNTR, R0
  _macro_WRITE _tm_TIME_CNTR+1, R0
  BITS _sr_DTMF_FLAG.bDIAL_INP
  
; Set the timer A for DTMF usage
  LD R0, TACON
  PUSH R0
  LD R0, #43H  ; timer A run, Fxx/1
  LD TACON, R0
  LD R0, TADATA
  PUSH R0
  LD R0, #134; the FREQ dividor
  LD TADATA, R0
  BITS ADCON.6   ; Enable the DA int 
; Backup the interrupt setting
  DI
  LD R0, IMR00
  PUSH R0
  LD R0, #00
  LD IMR00, R0
  LD R0, IMR01
  PUSH R0
  LD R0, #00
  LD IMR01, R0
  LD R0, IMR1
  PUSH R0 
  LD R0, #00 
  LD IMR1, R0
; Initial the interrupt setting  
  BITS ADCON.5    ; Enable the AD/DA clk
  BITS IMR00.0    ; Enable the DA INT
  BITS IMR00.1    ; Enable timer A
  BITS DACON.0    ; Enable DA
  EI
; Dial out the DTMF wave
 DA_LOOP:
  _macro_READ R2, _tm_LOWF_INDEX ; Get the low freq DA out
  _macro_READ R0, _tm_LOWF_INDEX+1
  _macro_READ R1, _tm_LOWF_CNTR
  ADD R0, R1
  INCC R2
  LD ILH, R2
  LD ILL, R0
  LDC @IL
  LD R0, TBL
  PUSH R0
  LD R1, TBH
  _macro_READ R0, _tm_HIGF_INDEX ; Get the high freq DA out
  _macro_READ R2, _tm_HIGF_INDEX+1
  _macro_READ R3, _tm_HIGF_CNTR
  ADD R2, R3
  INCC R0
  LD ILH, R0
  LD ILL, R2
  LDC @IL
  LD R2, TBL
  LD R3, TBH
  POP R0
  ADD R0, R2
  ADC R1, R3
  SR R1
  RRC R0
  SR R1
  RRC R0
  SR R1  
  RRC R0
  _macro_READ R1, _tm_LOWF_CNTR ; loop the DTMF wave
  INC R1
  _macro_READ R2, _tm_LOWFDA_CNT
  CP R1, R2
  Jp ULE, %F1
  LD R1, #0
 %1: 
  _macro_WRITE _tm_LOWF_CNTR, R1
  _macro_READ R1, _tm_HIGF_CNTR
  INC R1
  _macro_READ R2, _tm_HIGFDA_CNT
  CP R1, R2
  Jp ULE, %F2
  LD R1, #0
 %2: 
  _macro_WRITE _tm_HIGF_CNTR, R1
  LD _sr_DA_OUT, R0
 WAIT_DA:
  NOP 
  BITT _sr_DTMF_FLAG.bFINISH
  Jp Z, WAIT_DA
  BMS
  BITR _sr_DTMF_FLAG.bFINISH
  _macro_READ R0, _tm_TIME_CNTR ; output enough long time
  _macro_READ R1, _tm_TIME_CNTR+1
  INC R1
  INCC R0
  _macro_WRITE _tm_TIME_CNTR, R0
  _macro_WRITE _tm_TIME_CNTR+1, R1
  CP R1, #0
  Jp NZ, DA_LOOP
  CP R0, #cDIAL_TIME
  Jp ULE, DA_LOOP
  
  LD R0, #7FH   ; output enough long empty time
  LD _sr_DA_OUT, R0
 DTMF_WTIME:
  NOP 
  BITT _sr_DTMF_FLAG.bDTMF_FINISH 
  Jp Z, DTMF_WTIME
  BITR _sr_DTMF_FLAG.bDTMF_FINISH
  _macro_READ R0, _tm_TIME_CNTR
  _macro_READ R1, _tm_TIME_CNTR+1
  INC R1
  INCC R0
  _macro_WRITE _tm_TIME_CNTR, R0
  _macro_WRITE _tm_TIME_CNTR+1, R1
  CP R1, #0
  Jp NZ, DTMF_WTIME
  CP R0, #cDTSLI_TIME
  Jp ULE, DTMF_WTIME
  
  BITR _sr_DTMF_FLAG.bDIAL_INP
; Disable the DA clk and interrupt

  DI
  BITR ADCON.5  ; Disable the AD/DA clk
  BITR DACON.0  ; Disable the DA
; Restore the IMR  
  POP R0
  LD IMR1, R0
  POP R0
  LD IMR01, R0
  POP R0
  LD IMR00, R0
  POP R0
  LD TADATA, R0
  POP R0
  LD TACON, R0
  EI
  
_dial_out_exit:
  ld r3,#IS_TIMER_A_DIALOUT
  lcall InterruptServer_Unregist
  ld r3,#IS_DA_DIALOUT
  lcall InterruptServer_Unregist

  _macro_FREE STACK_SIZE
  bits p4.0
  
  RET
.end

用户评论

查看全部 条评论

发表评论请先 , 还没有账号?免费注册

发表评论

用户评论
技术交流、我要发言! 发表评论可获取积分! 请遵守相关规定。
上传电子资料
综合在线 日韩欧美 中文字幕_综合在线 日韩欧美 中文字幕精品视频 <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <文本链> <文本链> <文本链> <文本链> <文本链> <文本链>