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

📄 dtmffsk.asm

📁 An example to illustrate how to set the internal adjustable CID gain and receive FSK or DTMF data
💻 ASM
📖 第 1 页 / 共 2 页
字号:
        mov     a,cidfg
        jb      a.0,Ring_Int            ;Int occurs by Ring detection
;        jb      a.1,CAS_Int            ;Int occurs by Alert signal detection
        jb      a.2,FSK_Int             ;Int occurs by FSK data ready
        jb      a.3,DTMF_Int            ;Int occurs by DTMF data ready
;===Ring Detection Int=============
Ring_Int:
        mov     cidpcr,#FSK_Enable      ;Enable the power of FSK and DTMF receivers
        orl     cidpcr,#DTMF_Enable
        jmp 	End_Cid_Int
;===FSK Detection Int==============
FSK_Int:
        mov     Fsk_Data,fskdr          ;read fsk data from fskdr
        mov     Data_Buffer,Fsk_Data    ;put Fsk_Data in Data_Buffer
        jb      Channel_Seizure_Flag,Receive_FSK
;check 3 consucutive Channel Seizure (55h)        
        mov     a,Fsk_Data
        cjne    a,#C_Channel_Seizure,Reset_Counter  ;if not 55h initially, then reset counter and quit CID interrupt
        inc     Counter_Channel_Seizure         ;if 55h, then inc counter
        mov     a,Counter_Channel_Seizure
        cjne    a,#C_Ch_Seiz_Times,End_Cid_Int  ;check the number of recognizing channel seizure
        setb    Channel_Seizure_Flag            ;if the number of recognition is equal to C_Ch_Seiz_Times,set flag      
        jmp     Receive_FSK
Reset_Counter:
        mov     Counter_Channel_Seizure,#00h
        mov     a,Cidfg_R               ;Not FSK data, then check if the data is DTMF format.
        jb      a.3,DTMF_Int            ;Int occurs by DTMF data ready (DTMFDR flag)
        jmp     End_Cid_Int             ;if not DTMF_Int, it means the FSK int is trigerred by noise.
Receive_FSK:
Check_FSK_Format:
        jb      FSK_Format_Flag,FSK_Length  ;when receive 04H or 80H(FSK format code), then set flag 
        mov     a,Fsk_Data
        cjne    a,#C_Single_Format,Check_Multiple
        setb    FSK_Format_Flag         ;FSK format code is 04H
        add     a,Check_Sum             ;Do Check Sum
        mov     Check_Sum,a  
        call    Store_Data              ;Store data in RAM
        jmp     End_Cid_Int
Check_Multiple:
        cjne    a,#C_Multiple_Format,End_Cid_Int
        setb    FSK_Format_Flag         ;FSK format code is 80H
        setb    FSK_Multiple_Format_Flag
        add     a,Check_Sum             ;Do Check Sum
        mov     Check_Sum,a
        call    Store_Data              ;Store data in RAM
        jmp     End_Cid_Int
FSK_Length:                             ;receive FSK total length data
        jb      FSK_Length_Flag,FSK_Data_String
        mov     a,Fsk_Data
        mov     Data_Length,a
        setb    FSK_Length_Flag
        add     a,Check_Sum             ;Do Check Sum
        mov     Check_Sum,a
        call    Store_Data              ;Store data in RAM
        jmp     End_Cid_Int
FSK_Data_String:                        ;receiver FSK data string
        mov     a,Fsk_Data       
        add     a,Check_Sum             ;Do Check Sum
        mov     Check_Sum,a
        call    Store_Data              ;Store data in RAM       
        clr     c
        mov     a,Data_Length           ;Data_Length(FSK data string length) decreases one
        subb    a,#01h                  ;when receive one bye of FSK data string
        mov     Data_Length,a
        jnc     End_Cid_Int
        mov     a,Check_Sum             ;The last byte of FSK data string should be 2's complement of Check_Sum
        jnz     Receive_Error                             
        setb    CID_Finish_Flag         ;set when FSK receiving is correctly completely.
        mov     cidpcr,#00h             ;Disable CID power
        jmp     End_Cid_Int
Receive_Error:     
	setb	CID_Error_Flag		;if FSK error
;---end of FSK_Int----------

;===DTMF Detection Int======        
DTMF_Int:
        mov     cidpcr,#DTMF_Enable     ;-, -, -, -, CIDE, FSKE, ASE, DTMFE (Enable DTMF only, FSK disable)
        mov     DTMF_Data,dtmfdr        ;read fsk data from fskdr
        anl     DTMF_Data,#0fh          ;reserve the low nibble
        mov     Data_Buffer,DTMF_Data   ;show the DTMFDR to LCD from position1
        mov     a,DTMF_Data
        cjne    a,#0CH,Store_DTMF       ;Check if End-Code ("D") is received?
        setb    CID_Finish_Flag
Store_DTMF:        
        call    Store_Data              ;Store data in RAM
;---end of DTMF_Int----------        
        
End_Cid_Int:   
        mov     cidfg,#00              ;MUST clear CID flags in every CID interrupt routine
        anl     exif,#11111011b        ;then clear exif.2=CIDF
        reti
;----End 0f CID Interrupt Routine ---------------------
;=================================================================
;An example ot tore the received data into the RAM from 80h to DFh
;=================================================================
Store_Data:
        mov     r0,R0_Dp
        mov     @r0,Data_Buffer
        inc     r0      
        mov     R0_Dp,r0
        cjne    r0,#0d0h,Quit_Store_Data
        mov     r0,#080h
        mov     R0_Dp,r0
Quit_Store_Data:
        ret
;-----------------------------------------------------------------------------    
;======================================================
;The FSK flag initial Setting
;======================================================
FSK_Flag_Initial_Setting:
        mov     Counter_Channel_Seizure,#00h
        mov     Data_Length,#00h
        mov     Check_Sum,#00h
        mov     Flag0,#00h              ;clear all the flags
        anl     Cid_Flag1,#11000000b    ;reserve CID_Finish_Flag(bit6) and CID_Error_Flag(bit7)                	
        ret
;----------------------------------------------------------------------------
;==========================================================
;Set Internal CID gain control registers
;1. Set DTMFR1
;2. Set DTMFR2
;3. FSK/DTMF input gain set. PGAF<3:0>
;4. Alert tone input gain set. PGAF<7:4>           
;5. DTMF row(low) tone input gain set. PGD<3:0>
;6. DTMF column(High) tone input gain set. PGD<7:4>
;7. DTMF hysteresis set. PHAD<3:0>
;8. Alert tone input hysteresis set. PHAD<7:4>
;9. FSK Low pass filter input hysteresis set. PHFL<3:0>
;10.FSK input hysteresis set. PHFL<7:4>
;=========================================================
CID_Gain_Setting:                      
        mov     CIDGD,#00h              ;initiall set Data/Address 00h
        mov     CIDGA,#00h   
Set_DTMFR1:
        mov     CIDGD,#C_dtmfr1
        call    Latch_Data      
Set_DTMFR2:        
        inc     CIDGA                   ;CIDGA=01
        mov     CIDGD,#C_dtmfr2
        call    Latch_Data
PGAF_Set:
        inc     CIDGA                   ;CIDGA=02
        mov     a,#C_Gain_A
        swap    a
        orl     a,#C_Gain_FD            ;PGAF=(C_Gain_A, C_Gain_FD)   
        mov     CIDGD,a
        call    Latch_Data  
PGAD_Set:
        inc     CIDGA                   ;CIDGA=03
        mov     a,#C_Gain_Col           ;PGAD=(C_Gain_Col, C_Gain_Row)
        swap    a
        orl     a,#C_Gain_Row
        mov     CIDGD,a
        call    Latch_Data
PHAD_Set:
        inc     CIDGA                   ;CIDGA=04
        mov     a,#C_Hys_A              ;PHAD=(C_Hys_A, C_Hys_DTMF)
        swap    a
        orl     a,#C_Hys_DTMF
        mov     CIDGD,a
        call    Latch_Data
PHFL_Set:
        inc     CIDGA                   ;CIDGA=05
        mov     a,#C_Hys_FSK            ;PHFL=(C_Hys_FSK, C_Hys_LP)
        swap    a
        orl     a,#C_Hys_LP     
        mov     CIDGD,a
        call    Latch_Data
        ret
;---END OF CID GAIN SETTING--------------------------------
;===================================================
;Latch CIDGD into internal cid gain control register
;===================================================
Latch_Data:
        orl     CIDGA,#00001000b         ;set bit3 
        nop
        anl     CIDGA,#11110111b         ;clear bit3
        ret
;---END OF LATCH DATA--------------------------------------   
        end

⌨️ 快捷键说明

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