Mixed Signal PICtail™ Demo Board User’s Guide
DS51523A-page 32
2004 Microchip Technology Inc.
; OUTPUT - 5 cycles
;
; THEORY OF OPERATION - CHOOSING # OF STEPS
; Using the above #s:
; Minimum loop = 17 cycles
; Maximum loop = 46 cycles
; Maximum Low distortion = 5 + 22 + 5 = 32
; Maximum High distortion = 5 + 19 + 5 = 29
;
; These numbers need to be taken into consideration when choosing Fosc
; and the # of steps. Obviously, there is a balance between adding
; more steps (doesn’t have to be 2^X # of steps) and the distortion
; caused by not executing the minimum loop very often. The user could
; model this with most mathematical software packages to determine
; what is best for their system.
;
;*************************************************************************
DTMF UDATA
F_Low RES 1 ;# of cycles for the low frequency
F_Low_Rolling RES 1 ;last value of TMR0 when F_Low_Out was updated
F_Low_Step RES 1 ;SINE table index
F_Low_Out RES 1 ;Output duty cycle for F_Low
F_High RES 1 ;# of cycles for the high frequency
F_High_Rolling RES 1 ;last value of TMR0 when F_High_Out was updated
F_High_Step RES 1 ;SINE table index
F_High_Out RES 1 ;Output duty cycle for F_High
DTMF_Out RES 1 ;Output for DAC
ToneLength RES 1 ;# of F_High cycles used for delay
Key_Value RES 1 ;what # to dial?
GLOBAL F_Low, F_Low_Rolling,F_Low_Step, F_Low_Out, F_High, F_High_Rolling
GLOBAL F_High_Step, F_High_Out, DTMF_Out, ToneLength, Key_Value
GLOBAL Tone, Repeat_tone
EXTERN DAC_MSB, DAC_LSB, WriteToMCP492X
DTMF_SUB CODE
;
; Conditional Assembly Control Words
; ;No = 0, Yes = 1
#DEFINE Fosc_8000000 1 ;8MHz oscillator
#DEFINE Fosc_4000000 0 ;4MHz oscillator
#DEFINE Fosc_3570000 0 ;3.57MHz oscillator
#DEFINE ToneLength_150 0 ;150 ms tone per subroutine call
#DEFINE ToneLength_100 0 ;100 ms tone per subroutine call
#DEFINE ToneLength_50 1 ;50 ms tone per subroutine call
if Fosc_8000000
#DEFINE _32_steps 0 ;32 steps per cycle
#DEFINE _16_steps 1 ;16 steps per cycle
endif
if Fosc_4000000 | Fosc_3570000
#DEFINE _32_steps 0 ;32 steps per cycle
#DEFINE _16_steps 1 ;16 steps per cycle
endif
if _32_steps
;
;*************************************************************************
; This is a 32 level lookup table of a 7 bit SINE wave