;**********************************************************************
;IT'S A SMALL WORLD TUNE *
; 14-5-2010 *
; *
;**********************************************************************
list p=12F629
radix dec
include "p12f629.inc"
errorlevel -302 ; Dont complain about BANK 1 Registers during assembly
__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 delay "gap_1"
loops equ 23h ;loops of HIGH/LOW for 250mS or other duration
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
extend equ 2Bh ;used to increase number of loops
;****************************************************************
;Beginning of program
;****************************************************************
org 0x00
nop
nop
nop
nop
nop
SetUp bsf status, rp0 ;Bank 1
call 0x3FF ;retrieve factory calibration value
movwf OSCCAL ;update register with factory cal value
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 the gap between notes - 3rd byte in the table
;each unit is 10mS
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 *
;****************************************************************
;table values are as follows:
;1st value = value of HIGH and LOW for note
;2nd value = value to create 48mS note
;3rd value = x8 for long note = 48x5=380mS x5 for short note 48x5=240mS
table1 addwf pcl,f ;02h,1 add W to program counter
nop ;
retlw .14 ;loops - cycles of HIGH/LOW "E" It's
retlw .84 ;note - value of HIGH/LOW
retlw .50 ;gap between notes - uses "gap_1" delay
retlw .14 ; "F" - A
retlw .80
retlw .50
retlw .30 ;"G" world
retlw .142
retlw .50
retlw .30 ;"E" of
retlw .84
retlw .50
retlw .30 ;"C" laugh
retlw .105
retlw .50
retlw .14 ;"D"- ter
retlw .94
retlw .50
retlw .14 ;"C" a
retlw .105
retlw .50
retlw .30 ;"C" world
retlw .105
retlw .50
retlw .30 ;"B" of
retlw .113
retlw .50
retlw .40 ;"B" tears
retlw .113
retlw .50
retlw .14 ;"D"- It's
retlw .94
retlw .50
retlw .15 ;"E" a
retlw .84
retlw .50
retlw .30 ; "F" - world
retlw .80
retlw .50
retlw .30 ;"D"- of
retlw .94
retlw .50
retlw .40 ;"B" hopes
retlw .113
retlw .50
retlw .14 ;"C" and
retlw .105
retlw .50
retlw .14 ;"B" a
retlw .113
retlw .50
retlw .30 ;"A" world
retlw .126
retlw .20
retlw .30 ;"G" of
retlw .142
retlw .50
retlw .30 ;"G" fears
retlw .142
retlw .50
retlw .15 ;"E" There's
retlw .84
retlw .50
retlw .15 ; "F" - so
retlw .80
retlw .50
retlw .30 ;"G" much
retlw .142
retlw .50
retlw .14 ;"C" that
retlw .105
retlw .50
retlw .14 ;"D"- we
retlw .94
retlw .50
retlw .30 ;"E" share
retlw .84
retlw .50
retlw .14 ;"D"- that
retlw .94
retlw .50
retlw .14 ;"C" it's
retlw .105
retlw .50
retlw .15 ;"A" time
retlw .126
retlw .20
retlw .14 ;"D"- we're
retlw .94
retlw .50
retlw .15 ;"E" a
retlw .84
retlw .50
retlw .30 ; "F" - ware
retlw .80
retlw .50
retlw .14 ;"E" It's
retlw .84
retlw .50
retlw .14 ;"D" A
retlw .94
retlw .50
retlw .30 ;"G" small
retlw .142
retlw .50
retlw .14 ; "F" - world
retlw .80
retlw .50
retlw .30 ; "E" - af
retlw .84
retlw .50
retlw .14 ;"D" ter
retlw .94
retlw .50
retlw .60 ;"C" all
retlw .105
retlw .240
retlw .45 ;"C" It's
retlw .105
retlw .50
retlw .14 ;"C" a
retlw .105
retlw .50
retlw .30 ; "E" - small
retlw .84
retlw .50
retlw .30 ;"C" world
retlw .105
retlw .50
retlw .45 ;"D" af
retlw .94
retlw .50
retlw .15 ;"D" ter
retlw .94
retlw .50
retlw .60 ;"D" all
retlw .94
retlw .240
retlw .48 ; "D" -It's
retlw .94
retlw .50
retlw .14 ;"D"- A
retlw .94
retlw .50
retlw .30 ;"F" small
retlw .80
retlw .50
retlw .24 ;"D" word
retlw .94
retlw .50
retlw .48 ;"E" af
retlw .84
retlw .50
retlw .14 ;"E" ter
retlw .84
retlw .20
retlw .48 ; "E" - all
retlw .84
retlw .240
retlw .48 ;"E"- It's
retlw .84
retlw .20
retlw .14 ;"E" A
retlw .84
retlw .20
retlw .50 ;"G+" small
retlw .71
retlw .20
retlw .24 ;"E" world
retlw .84
retlw .20
retlw .48 ;"F" af
retlw .80
retlw .20
retlw .14 ; "F" -ter
retlw .80
retlw .20
retlw .14 ; "F" - all
retlw .80
retlw .240
retlw .30 ;"E" it's
retlw .84
retlw .20
retlw .14 ;"D"- A
retlw .94
retlw .50
retlw .40 ;"G" small
retlw .142
retlw .50
retlw .40 ;"B" small
retlw .113
retlw .50
retlw .55 ;"C" word
retlw .105
retlw .50
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
eee movlw 10
movwf extend
ttt 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 extend,1
goto ttt
decfsz loops,f
goto eee
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