;**********************************************
;HAPPY BIRTHDAY TUNE *
; 11-5-2010 *
; *
;**********************************************
list p=12F629
radix dec
include "p12f629.inc"
errorlevel -302 ; Don't complain about BANK 1 Registers
__CONFIG _MCLRE_OFF & _CP_OFF & _WDT_OFF
& _INTRC_OSC_NOCLKOUT ;Internal osc.
;===============================
;
; Configuration Bits
;
;===============================
note equ 21h ;value of HIGH and LOW for note
gap equ 22h ;gap between notes - uses "gap_1" delay
loops equ 23h ;loops of HIGH/LOW
temp1 equ 24h ;temp file for note
jump equ 25h
D1 equ 26h ;used in 250mS delay
D2 equ 27h ;used in 250mS delay
D3 equ 28h ;used in 250mS delay
gapDela equ 29h ;used in gap delay
tempA equ 2Ah ;used in gap delay
;****************************************************************
;Beginning of program
;****************************************************************
org 0x00
nop
nop
nop
nop
nop
SetUp bsf status, rp0 ;Bank 1
call 0x3FF ;retrieve calibration value
movwf OSCCAL ;
movlw b'00001011' ;Set TRIS
movwf TRISIO ;GP2,4 outputs
bcf status, rp0 ;bank 0
movlw 07h ;turn off Comparator
movwf CMCON ;must be placed in bank 0
clrf jump ;jump value for table
goto M1
;****************************************************************
;* Delays *
;****************************************************************
;gap_1 produces gap between notes - 3rd byte in table
gap_1 movlw .2
movwf gapDela
gap_1a decfsz tempA
goto gap_1a
decfsz gapDela,1 ;produces loops
goto gap_1a
decfsz gap,1 ;
goto gap_1
retlw 00
;250mS second delay
_250mS nop
goto $+1
decfsz D1,1
goto _250mS
decfsz D2,1
goto _250mS
retlw 00
;********************************
;* Table *
;********************************
table1 addwf pcl,f ;02h,1 add W to program counter
nop ;
retlw .100 ;loops - cycles of HIGH/LOW "G" -Hap
retlw .142 ;note - value of HIGH/LOW
retlw .50 ;gap between notes
retlw .100 ;"G"-py
retlw .142
retlw .50
retlw .220 ;"A" birth
retlw .126
retlw .50
retlw .200 ;"G" day
retlw .142
retlw .50
retlw .240 ;"C" to
retlw .105
retlw .50
retlw .240 ;"B" you
retlw .113
retlw .240
retlw .97 ; "G" -Hap
retlw .142
retlw .20
retlw .97 ;"G"-py
retlw .142
retlw .20
retlw .220 ;"A" birth
retlw .126
retlw .20
retlw .200 ;"G" day
retlw .142
retlw .20
retlw .240 ;"D" to
retlw .94
retlw .20
retlw .240 ;"C" you
retlw .105
retlw .240
retlw .97 ; "G" -Hap
retlw .142
retlw .20
retlw .97 ;"G" -py
retlw .142
retlw .20
retlw .240 ;"G+"- BIRTH
retlw .71
retlw .1
retlw .240 ;"G+"- BIRTH
retlw .71
retlw .20
retlw .240 ;"E" -day
retlw .84
retlw .20
retlw .240 ;"C"
retlw .105
retlw .20
retlw .240 ;"B"
retlw .113
retlw .20
retlw .220 ;"A"
retlw .126
retlw .240
retlw .240 ;"F"
retlw .80
retlw .2
retlw .240 ;"F"
retlw .80
retlw .2
retlw .240 ;"E"
retlw .84
retlw .2
retlw .240 ;"C"
retlw .105
retlw .2
retlw .240 ;"D"
retlw .94
retlw .2
retlw .240 ;"C"
retlw .105
retlw .2
retlw 0FFh
M1 call _250mS
call _250mS
Main incf jump,1 ;increment pointer
movf jump,w
call table1
movwf loops ;first value from table
movlw 0ffh
xorwf loops,w ;see if value is "0ffh"
btfsc status,z
goto SetUp
incf jump,1
movf jump,w
call table1
movwf temp1 ;temp for note for HIGH/LOW
tune movf temp1,w
movwf note
bsf gpio,2
bcf gpio,4
goto $+1
goto $+1
goto $+1
decfsz note,1
goto $-4
movf temp1,w
movwf note
bcf gpio,2
bsf gpio,4
goto $+1
goto $+1
goto $+1
decfsz note,1
goto $-4
decfsz loops,f
goto tune
incf jump,1 ;look for gap value
movf jump,w
call table1
movwf gap
bcf gpio,2 ;to produce silence
bcf gpio,4 ;to produce silence
call gap_1 ;mS gap
goto Main
END
|