Mixed Signal PICtail™ Demo Board User’s Guide
DS51523A-page 38
2004 Microchip Technology Inc.
movlw .32
endif
if _16_steps
movlw .16
endif
movwf F_Low_Step
movwf F_High_Step
movlw 01Fh
movwf F_Low_Out
movwf F_High_Out
movf TMR0,W
movwf F_Low_Rolling
movwf F_High_Rolling
movlw 0Fh
andwf Key_Value,F
movf Key_Value,W
call F_Low_table
movwf F_Low
movf Key_Value,W
call F_High_table
movwf F_High
Repeat_tone ;Call here to repeat the tone for ToneLength
;The following inits the ToneLength delay reg’s
movf Key_Value,W
call ToneLength_table
movwf ToneLength
test_F_Low ;Low frequency tone loop timer
movf F_Low_Rolling,W
subwf TMR0,W ;result = time since last update
subwf F_Low,W ;Carry bit determines if enough time has elapsed
btfsc STATUS,C
goto test_F_High ;do not update the SINE wave yet
movf F_Low,W
addwf F_Low_Rolling,F ;Very Important to add to the last reference
;instead of using the actual timer value
decfsz F_Low_Step,F ;update the step count
goto no_reset_F_Low_Step
if _32_steps
movlw .32
endif
if _16_steps
movlw .16
endif
movwf F_Low_Step
no_reset_F_Low_Step
movf F_Low_Step,W
call SINE_Table_7bit ;fetch the corresponding Sin value
movwf F_Low_Out ;store result
test_F_High ;High frequency tone loop timer
movf F_High_Rolling,W
subwf TMR0,W ;result = time since last update
subwf F_High,W ;Carry bit determines if enough time has elapsed
btfsc STATUS,C
goto update_output ;do not update the SINE wave yet
movf F_High,W
addwf F_High_Rolling,F ;Very Important to add to the last reference
;instead of using the actual timer value
decfsz F_High_Step,F ;update the step count