📄 sub_dci_kickoff.s
字号:
;START_HEADER
;
; dsPIC30F6014 Demo Source File
; (c) Copyright 2005 Microchip Technology, All rights reserved
;
; --------------------------------------------------------------------------
; File Revision History:
; --------------------------------------------------------------------------
;
; $Log: sub_dci_kickoff.s,v $
; Revision 1.3 2005/04/04 23:39:00 VasukiH
; Updated comments in header
;
; Revision 1.2 2005/04/04 23:14:32 VasukiH
; Updates for MPLAB C30 v1.30 compatiblity
;
; Revision 1.1.1.1 2003/08/23 00:38:33 VasukiH
; First import of demo source into CVS Repository
;
;
;
; --------------------------------------------------------------------------
;
; Software and Development Tools Info:
; --------------------------------------------------------------------------
; Tool Version
; --------------------------------------------------------------------------
; MPLAB IDE 7.0
; MPLAB C30 Toolsuite 1.30
; dsPICDEM(TM) Processor Board 1.10
; --------------------------------------------------------------------------
;
; File Notes:
;
; 1. This subroutine maps a number received by the UART,
; to a DTMF tone and kicks off DCI transmissions.
;
; 2. All tone samples are stored in Program Memory, so we use PSV to access
; this data.
;
; 3. A tone sample is 100 milliseconds long and is followed by
; 15 milliseconds of silence.
;
; 4. A tone sample is obtained by adding amplitudes of the sinusoid components.
; The low frequency omponent has a signal strength 8 dB higher than the
; high frequency component
;
;END_HEADER
.include "p30fxxxx.inc"
.include "common.inc"
.global DCIUnavailable, LowTonePtr, HighTonePtr
.global DTMFSamplesCount, DTMFSilenceCount, TonesRecord
.section .nbss, bss, near
.align 2
LowTonePtr: .space WORD
HighTonePtr: .space WORD
.section .ndata, data, near
.align WORD
DCIUnavailable: .hword 0x0000 ;Flag that indicates the DCI
;module is transmitting a tone
;Flag is used to prevent one tone
;"over-writing" another
DTMFSamplesCount: .hword 0x0000 ;Keeps a count of number of DTMF
;samples left to transmit
DTMFSilenceCount: .hword 0x0000 ;Keeps a count of number of Silence
;samples left to transmit
TonesRecord: .hword psvoffset(sin941)
.hword psvoffset(sin1336)
.hword psvoffset(sin697)
.hword psvoffset(sin1209)
.hword psvoffset(sin697)
.hword psvoffset(sin1336)
.hword psvoffset(sin697)
.hword psvoffset(sin1477)
.hword psvoffset(sin770)
.hword psvoffset(sin1209)
.hword psvoffset(sin770)
.hword psvoffset(sin1336)
.hword psvoffset(sin770)
.hword psvoffset(sin1477)
.hword psvoffset(sin852)
.hword psvoffset(sin1209)
.hword psvoffset(sin852)
.hword psvoffset(sin1336)
.hword psvoffset(sin852)
.hword psvoffset(sin1477)
.global _sub_dci_kickoff
.section .text
_sub_dci_kickoff:
push w1
push.d w2
sub.b #0x30, w0 ;First check what digit has been supplied
try0: cp.b w0, #0x0 ;in the range 0-9
bra nz, try1 ;Subtract 0x30 to convert ASCII to binary
bra initiateDCI
try1: cp.b w0, #0x1
bra nz, try2
bra initiateDCI
try2: cp.b w0, #0x2
bra nz, try3
bra initiateDCI
try3: cp.b w0, #0x3
bra nz, try4
bra initiateDCI
try4: cp.b w0, #0x4
bra nz, try5
bra initiateDCI
try5: cp.b w0, #0x5
bra nz, try6
bra initiateDCI
try6: cp.b w0, #0x6
bra nz, try7
bra initiateDCI
try7: cp.b w0, #0x7
bra nz, try8
bra initiateDCI
try8: cp.b w0, #0x8
bra nz, try9
bra initiateDCI
try9: cp.b w0, #0x9
bra nz, exit_dci_kickoff
bra initiateDCI
exit_dci_kickoff:
pop.d w2
pop w1
return
initiateDCI:
cp0 DtmfPauseFlag ;If the PauseFlag is set, add Pause time
bra nz, AddPauseTime ;to the Silent time (OFF time)
mov #SILENTMAX, w1
mov w1, DTMFSilenceCount
bra load_samp_cnt ;For a single tone, 720 samples sampled at
AddPauseTime: ;7200 Hz is played so as to generate a 100ms
mov #SIL_PLUS_PAUSE, w1 ;on time duration
mov w1, DTMFSilenceCount ;Load the count values for ON time and OFF time
load_samp_cnt:
mov #NUMSAMPSTORED, w1
mov w1, DTMFSamplesCount
mov #TonesRecord, w1 ;Use the TonesRecord to get the pointers to
ze w0, w0 ;the high and low frequency tone samples
sl w0, #2, w0 ;which are stored in PS.
add w1, w0, w0
mov [w0++], w1
mov [w0++], w2
push CORCON
push PSVPAG ;Enable PSV to access tones
bset CORCON, #PSV
mov #psvpage(sin697), w0
mov w0, PSVPAG
nop
mov [w1++], w0
mov [w2++], w3
add w0, w3, w0 ;Add the two sinusoids to get a DTMF Tone
bclr w0, #0 ;LS-bit cleared so that the codec does not
mov w0, TXBUF0 ;assume a secondary frame request is being made
mov [w1++], w0
mov [w2++], w3
add w0, w3, w0
bclr w0, #0 ;LS-bit cleared so that the codec does not
mov w0, TXBUF1 ;assume a secondary frame request is being made
mov [w1++], w0
mov [w2++], w3
add w0, w3, w0
bclr w0, #0
mov w0, TXBUF2 ;Load TXBUF0-TXBUF3
mov [w1++], w0
mov [w2++], w3
add w0, w3, w0
bclr w0, #0
mov w0, TXBUF3
dec2 DTMFSamplesCount ;Decrement samples count by 4 since
dec2 DTMFSamplesCount ;we sent 4 samples out
mov w1, LowTonePtr ;Update the High and Low tone pointers
mov w2, HighTonePtr
pop PSVPAG ;Restore CORCON, PSVPAG
nop
pop CORCON
bclr IFS2, #DCIIF ;Clear the DCI Interrupt flag
bra exit_dci_kickoff
.end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -