电子发烧友App

硬声App

0
  • 聊天消息
  • 系统消息
  • 评论与回复
登录后你可以
  • 下载海量资料
  • 学习在线课程
  • 观看技术视频
  • 写文章/发帖/加入社区
会员中心
创作中心

完善资料让更多小伙伴认识你,还能领取20积分哦,立即完善>

3天内不再提示
电子发烧友网>电子资料下载>消费电子>手机类>SPDA_DTMF软拨号

SPDA_DTMF软拨号

2006-04-18 | rar | 470 | 次下载 | 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, #  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, #  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, #  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

下载该资料的人也在下载 下载该资料的人还在阅读
更多 >

评论

查看更多

下载排行

本周

  1. 1电子电路原理第七版PDF电子教材免费下载
  2. 0.00 MB  |  1490次下载  |  免费
  3. 2单片机典型实例介绍
  4. 18.19 MB  |  92次下载  |  1 积分
  5. 3S7-200PLC编程实例详细资料
  6. 1.17 MB  |  27次下载  |  1 积分
  7. 4笔记本电脑主板的元件识别和讲解说明
  8. 4.28 MB  |  18次下载  |  4 积分
  9. 5开关电源原理及各功能电路详解
  10. 0.38 MB  |  10次下载  |  免费
  11. 6基于AT89C2051/4051单片机编程器的实验
  12. 0.11 MB  |  4次下载  |  免费
  13. 7蓝牙设备在嵌入式领域的广泛应用
  14. 0.63 MB  |  3次下载  |  免费
  15. 89天练会电子电路识图
  16. 5.91 MB  |  3次下载  |  免费

本月

  1. 1OrCAD10.5下载OrCAD10.5中文版软件
  2. 0.00 MB  |  234313次下载  |  免费
  3. 2PADS 9.0 2009最新版 -下载
  4. 0.00 MB  |  66304次下载  |  免费
  5. 3protel99下载protel99软件下载(中文版)
  6. 0.00 MB  |  51209次下载  |  免费
  7. 4LabView 8.0 专业版下载 (3CD完整版)
  8. 0.00 MB  |  51043次下载  |  免费
  9. 5555集成电路应用800例(新编版)
  10. 0.00 MB  |  33562次下载  |  免费
  11. 6接口电路图大全
  12. 未知  |  30320次下载  |  免费
  13. 7Multisim 10下载Multisim 10 中文版
  14. 0.00 MB  |  28588次下载  |  免费
  15. 8开关电源设计实例指南
  16. 未知  |  21539次下载  |  免费

总榜

  1. 1matlab软件下载入口
  2. 未知  |  935053次下载  |  免费
  3. 2protel99se软件下载(可英文版转中文版)
  4. 78.1 MB  |  537791次下载  |  免费
  5. 3MATLAB 7.1 下载 (含软件介绍)
  6. 未知  |  420026次下载  |  免费
  7. 4OrCAD10.5下载OrCAD10.5中文版软件
  8. 0.00 MB  |  234313次下载  |  免费
  9. 5Altium DXP2002下载入口
  10. 未知  |  233045次下载  |  免费
  11. 6电路仿真软件multisim 10.0免费下载
  12. 340992  |  191183次下载  |  免费
  13. 7十天学会AVR单片机与C语言视频教程 下载
  14. 158M  |  183277次下载  |  免费
  15. 8proe5.0野火版下载(中文版免费下载)
  16. 未知  |  138039次下载  |  免费