;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; MicroChip PIC16F84 Music Generator ; ; Jonathan Wheeler ; June 29, 2005 ; revised and updated by Michael Helm ; Dec 4, 2005 ; ; This program is capable of generating notes on the octaves of C3 (middle C) ; through B4. CS is C# (sharp), which is equivalent to CF, which is Cb (flat). ; The note coding sequence is thus: C3 is the lowest note available, D3 is note ; above, etc all the way through G3 and on up to B3. The next octave starts at ; C4 and continues with D4, E4, etc on up through B4 as the highest possible note. ; Effectively two octaves are covered including sharps and flats as appropriate. ; ; ; Each note call will generate that particular tone for 1/6 of a second in ; slow mode, and 1/12 of a second in fast mode. Since higher pitched tones ; complete their oscillations more quickly, more oscillations must be performed ; in order for the note to play for the same duration of time as the lower notes. ; There are only two inputs: tempo (speed) and the song selection. Tempo ; is checked each note and is internal to the lower level tone generation ; functions, which makes the change immediate. The song input selection is ; checked once or twice per measure (roughly every 4 notes), so there is a slight but ; reasonable delay. ; ; There are two songs encoded in this program, song 1 is Yankee Doodle and ; song 2 is London Bridge. These are included as examples as a starting point ; to show you how to program a tune of your choice. Longer tunes can be programmed ; if repeating measures are set up as subroutines as shown with song 2 where ; measures 1 and 3 are identical and measures 2 and 4 are identical. ; ; The output signal is a square wave of the appropriate audio rate on PORT A pin 0. ; Two inputs on PORT B are used to select between tunes and to select the tempo ; rate. These inputs are set to logic high or low to make the appropriate selection. ; ; The bulk of the code is devoted to the note generators, which are in the latter ; part of the code. ; ; ; Pin definitions ; ; PORTA - all 5 available pins are outputs ; pin 0 - speaker output ; pin 1 - not used ; pin 2 - not used ; pin 3 - not used ; pin 4 - not used ; ; PORTB - all 8 available pins are inputs ; Pullups are turned on for Port B in the options register ; pin 0 - select song input ; pin 1 - select tempo input ; pin 2 - not used ; pin 3 - not used ; pin 4 - not used ; pin 5 - not used ; pin 6 - not used ; pin 7 - not used ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; below is necessary "boilerplate" code ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ERRORLEVEL 0, -302, -203, -205 ;suppress Argument out of range errors and "found directive on column 1" errors LIST P=16F84, F=INHX8M, R=HEX include "p16f84.inc" __FUSES _CP_OFF & _XT_OSC & _WDT_OFF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; equates ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DEBUG EQU 0 ; change to 1 for debug mode, 0 for normal mode VERSION EQU 1 ; current rev number SpeakerOutput EQU 0 ; this will be PORTA bit 0 SongInput EQU 0 ; this will be PORTB bit 0 TempoInput EQU 1 ; this will be PORTB bit 1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; macro definitions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; CheckIfSong1 macro ; when playing Song2, check whether we need to switch to Song1 btfss PORTB, SongInput goto Song1 endm CheckIfSong2 macro ; when playing Song1, check whether we need to switch to Song2 btfsc PORTB, SongInput goto Song2 endm ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ram variable definitions - these are stored in the register file space ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; cblock 0c ; directive to start our variable declaration block ; how many times to oscillate a particular note in order to insure that all ; notes -- both "high" rapidly oscillating notes and "low" slowly oscillating ; notes play for the same duration of time. used by the "play" functions below playLoopCount ; how long to wait until flipping the voltage output for a particular note. ; used by the "wait" functions below. waitCount endc ; directive to end our variable declaration block ; last available RAM address is at 2f ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; main program ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; org 0 ; start program at address 0 goto Begin ; jump past the interrupt handler below dw VERSION ; since this is a useless location, store version number here ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; timer interrupt handler code ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; org 4 ; interrupt processing starts here ; this is a fixed system address that we must use retfie ; return from interrupt ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; program initialization - set up the ports and some other configuration stuff ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Begin bsf STATUS, RP0 ; select bank 1 so we can set the direction bits movlw b'00000000' ; low 5 bits of PORTA are output movwf TRISA ; set direction bits for port A movlw b'11111111' ; all bits for PORTB are input movwf TRISB ; set direction bits for port B movlw b'00000000' ; pull ups on port B, timer 0 gets prescale 2 movwf OPTION_REG ; sets up the OPTIONS register bcf STATUS, RP0 ;select bank 0 again so we can use PORTA and PORTB clrf PORTA ; clear port A latch clrf PORTB ; clear port B latch ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; program start ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MainLoop CheckIfSong2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Song1 ; Yankee Doodle - American Folk song ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; measure 1 call playC4 ; calling once is equivalent to an 1/8th note call playNothing call playC4 call playNothing call playD4 call playNothing call playE4 call playNothing call playF4 call playNothing call playE4 call playNothing call playD4 call playNothing call playC4 call playNothing CheckIfSong2 call playB3 call playNothing call playG3 call playNothing call playA3 call playNothing call playB3 call playNothing call playC4 ;calling twice is equivalent to 1/4 note call playC4 call playNothing call playC4 call playC4 call playNothing CheckIfSong2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; measure 2 call playC4 call playNothing call playC4 call playNothing call playD4 call playNothing call playE4 call playNothing call playC4 call playNothing call playE4 call playNothing call playD4 call playNothing call playG3 call playNothing CheckIfSong2 call playC4 call playNothing call playC4 call playNothing call playD4 call playNothing call playE4 call playNothing call playC4 call playC4 call playNothing call playB3 call playB3 call playNothing CheckIfSong2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; measure 3 call playC4 call playNothing call playC4 call playNothing call playD4 call playNothing call playE4 call playNothing call playF4 call playNothing call playE4 call playNothing call playD4 call playNothing call playC4 call playNothing CheckIfSong2 call playB3 call playNothing call playG3 call playNothing call playA3 call playNothing call playB3 call playNothing call playC4 call playC4 call playNothing call playC4 call playC4 call playNothing CheckIfSong2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; measure 4 call playA3 call playNothing call playB3 call playNothing call playA3 call playNothing call playG3 call playNothing call playA3 call playNothing call playB3 call playNothing call playC4 call playC4 call playNothing CheckIfSong2 call playG3 call playNothing call playA3 call playNothing call playG3 call playNothing call playF3 call playNothing call playE3 call playE3 call playNothing call playG3 call playG3 call playNothing CheckIfSong2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; measure 5 call playA3 call playNothing call playB3 call playNothing call playA3 call playNothing call playG3 call playNothing call playA3 call playNothing call playB3 call playNothing call playC4 call playNothing call playA3 call playNothing CheckIfSong2 call playG3 call playNothing call playC4 call playNothing call playB3 call playNothing call playD4 call playNothing call playC4 call playC4 call playNothing call playC4 call playC4 call playNothing CheckIfSong2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; measure 6 call playC4 call playNothing call playC4 call playNothing call playD4 call playNothing call playE4 call playNothing call playF4 call playNothing call playE4 call playNothing call playD4 call playNothing call playC4 call playNothing CheckIfSong2 call playB3 call playNothing call playG3 call playNothing call playA3 call playNothing call playB3 call playNothing call playC4 call playC4 call playC4 call playC4 call playNothing call playNothing call playNothing call playNothing call playNothing call playNothing call playNothing call playNothing CheckIfSong2 goto Song1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Song2 ; London Bridge - British Folk Song ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; measure 1 call Song2_Measure1and3 ;since measure 1 and 3 are the same, this is more efficient coding ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; measure 2 call Song2_Measure2and4 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; measure 3 call Song2_Measure1and3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; measure 4 call Song2_Measure2and4 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; measure 5 call playD4 call playD4 call playD4 call playD4 call playNothing call playG4 call playG4 call playG4 call playG4 call playNothing call playE4 call playNothing call playC4 call playC4 call playC4 call playC4 call playC4 call playNothing call playNothing call playNothing call playNothing call playNothing call playNothing call playNothing call playNothing CheckIfSong1 goto Song2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Song2_Measure1and3 call playG4 call playNothing call playA4 call playNothing call playG4 call playNothing call playF4 call playNothing call playE4 call playNothing call playF4 call playNothing call playG4 call playG4 call playNothing CheckIfSong1 call playD4 call playNothing call playE4 call playNothing call playF4 call playF4 call playNothing call playE4 call playNothing call playF4 call playNothing call playG4 call playG4 call playNothing CheckIfSong1 return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Song2_Measure2and4 call playG4 call playNothing call playA4 call playNothing call playG4 call playNothing call playF4 call playNothing call playE4 call playNothing call playF4 call playNothing call playG4 call playG4 call playNothing CheckIfSong1 call playD4 call playD4 call playNothing call playG4 call playG4 call playNothing call playE4 call playNothing call playC4 call playC4 call playC4 call playNothing CheckIfSong1 return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; play and delay funtions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; 1 second / 6 = 166 milliseconds playNothing btfss PORTB, TempoInput goto playNothing_SlowTempo goto playNothing_FastTempo playNothing_SlowTempo movlw D'166' ; set up a count for this loop movwf playLoopCount ; save it into the variable goto playNothing_loop playNothing_FastTempo movlw D'83' ; set up a count for this loop movwf playLoopCount ; save it into the variable playNothing_loop call wait1ms decfsz playLoopCount, f ; see if we are done yet goto playNothing_loop ; no, loop some more return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; wait1ms waits for one millisecond wait1ms movlw D'100' ;set up a count for this loop = 100 loops movwf waitCount ; save it into the variable call waitLoop return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; C3 - 262 Hz / 6 = 43.666 playC3 btfss PORTB, TempoInput goto playC3_SlowTempo goto playC3_FastTempo playC3_SlowTempo movlw D'44' ; set up a count for this loop movwf playLoopCount ; save it into the variable goto playC3_loop playC3_FastTempo movlw D'21' ; set up a count for this loop movwf playLoopCount ; save it into the variable playC3_loop bcf PORTA, SpeakerOutput call waitC3 bsf PORTA, SpeakerOutput call waitC3 decfsz playLoopCount, f ; see if we are done yet goto playC3_loop ; no, loop some more return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; C3 - 262 Hz - 3816 microsecond oscillations - 1908 microsecond flips waitC3 movlw D'191' ; set up a count for this loop movwf waitCount ; save it into the variable call waitLoop return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; CS3 - DF3 - 277 Hz / 6 = 46.166 playCS3 playDF3 btfss PORTB, TempoInput goto playCS3_SlowTempo goto playCS3_FastTempo playCS3_SlowTempo movlw D'46' ; set up a count for this loop movwf playLoopCount ; save it into the variable goto playCS3_loop playCS3_FastTempo movlw D'23' ; set up a count for this loop movwf playLoopCount ; save it into the variable playCS3_loop bcf PORTA, SpeakerOutput call waitCS3 bsf PORTA, SpeakerOutput call waitCS3 decfsz playLoopCount, f ; see if we are done yet goto playCS3_loop ; no, loop some more return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; CS3 - (DF3) - 277 Hz - 3610 microsecond oscillations - 1805 microsecond flips waitCS3 movlw D'181' ; set up a count for this loop movwf waitCount ; save it into the variable call waitLoop return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; D3 - 294 Hz / 6 = 49 playD3 btfss PORTB, TempoInput goto playD3_SlowTempo goto playD3_FastTempo playD3_SlowTempo movlw D'49' ; set up a count for this loop movwf playLoopCount ; save it into the variable goto playD3_loop playD3_FastTempo movlw D'25' ; set up a count for this loop movwf playLoopCount ; save it into the variable playD3_loop bcf PORTA, SpeakerOutput call waitD3 bsf PORTA, SpeakerOutput call waitD3 decfsz playLoopCount, f ; see if we are done yet goto playD3_loop ; no, loop some more return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; D3 - 294 Hz - 3402 microsecond oscillations - 1701 microsecond flips waitD3 movlw D'170' ; set up a count for this loop movwf waitCount ; save it into the variable call waitLoop return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; DS3 - EF3 - 311 Hz / 6 = 51.833 playDS3 playEF3 btfss PORTB, TempoInput goto playDS3_SlowTempo goto playDS3_FastTempo playDS3_SlowTempo movlw D'52' ; set up a count for this loop movwf playLoopCount ; save it into the variable goto playDS3_loop playDS3_FastTempo movlw D'26' ; set up a count for this loop movwf playLoopCount ; save it into the variable playDS3_loop bcf PORTA, SpeakerOutput call waitDS3 bsf PORTA, SpeakerOutput call waitDS3 decfsz playLoopCount, f ; see if we are done yet goto playDS3_loop ; no, loop some more return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; DS3 - (EF3) - 311 Hz - 3216 microsecond oscillations - 1608 microsecond flips waitDS3 movlw D'162' ; set up a count for this loop movwf waitCount ; save it into the variable call waitLoop return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; E3 - 330 Hz / 6 = 55 playE3 btfss PORTB, TempoInput goto playE3_SlowTempo goto playE3_FastTempo playE3_SlowTempo movlw D'55' ; set up a count for this loop movwf playLoopCount ; save it into the variable goto playE3_loop playE3_FastTempo movlw D'28' ; set up a count for this loop movwf playLoopCount ; save it into the variable playE3_loop bcf PORTA, SpeakerOutput call waitE3 bsf PORTA, SpeakerOutput call waitE3 decfsz playLoopCount, f ; see if we are done yet goto playE3_loop ; no, loop some more return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; E3 - 330 Hz - 3030 microsecond oscillations - 1515 microsecond flips waitE3 movlw D'152' ; set up a count for this loop movwf waitCount ; save it into the variable call waitLoop return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; F3 - 349 Hz / 6 = 58.166 playF3 btfss PORTB, TempoInput goto playF3_SlowTempo goto playF3_FastTempo playF3_SlowTempo movlw D'58' ; set up a count for this loop movwf playLoopCount ; save it into the variable goto playF3_loop playF3_FastTempo movlw D'29' ; set up a count for this loop movwf playLoopCount ; save it into the variable playF3_loop bcf PORTA, SpeakerOutput call waitF3 bsf PORTA, SpeakerOutput call waitF3 decfsz playLoopCount, f ; see if we are done yet goto playF3_loop ; no, loop some more return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; F3 - 349 Hz - 2866 microsecond oscillations - 1433 microsecond flips waitF3 movlw D'143' ; set up a count for this loop movwf waitCount ; save it into the variable call waitLoop return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; FS3 - GF3 - 370 Hz / 6 = 61.666 playFS3 playGF3 btfss PORTB, TempoInput goto playFS3_SlowTempo goto playFS3_FastTempo playFS3_SlowTempo movlw D'62' ; set up a count for this loop movwf playLoopCount ; save it into the variable goto playFS3_loop playFS3_FastTempo movlw D'31' ; set up a count for this loop movwf playLoopCount ; save it into the variable playFS3_loop bcf PORTA, SpeakerOutput call waitFS3 bsf PORTA, SpeakerOutput call waitFS3 decfsz playLoopCount, f ; see if we are done yet goto playFS3_loop ; no, loop some more return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; FS3 - (GF3) - 370 Hz - 2702 microsecond oscillations - 1351 microsecond flips waitFS3 movlw D'135' ; set up a count for this loop movwf waitCount ; save it into the variable call waitLoop return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; G3 - 392 Hz / 6 = 65.333 playG3 btfss PORTB, TempoInput goto playG3_SlowTempo goto playG3_FastTempo playG3_SlowTempo movlw D'65' ; set up a count for this loop movwf playLoopCount ; save it into the variable goto playG3_loop playG3_FastTempo movlw D'33' ; set up a count for this loop movwf playLoopCount ; save it into the variable playG3_loop bcf PORTA, SpeakerOutput call waitG3 bsf PORTA, SpeakerOutput call waitG3 decfsz playLoopCount, f ; see if we are done yet goto playG3_loop ; no, loop some more return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; G3 - 392 Hz - 2552 microsecond oscillations - 1276 microsecond flips waitG3 movlw D'128' ; set up a count for this loop movwf waitCount ; save it into the variable call waitLoop return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; GS3 - AF3 - 415 Hz / 6 = 69.166 playGS3 playAF3 btfss PORTB, TempoInput goto playGS3_SlowTempo goto playGS3_FastTempo playGS3_SlowTempo movlw D'69' ; set up a count for this loop movwf playLoopCount ; save it into the variable goto playGS3_loop playGS3_FastTempo movlw D'35' ; set up a count for this loop movwf playLoopCount ; save it into the variable playGS3_loop bcf PORTA, SpeakerOutput call waitGS3 bsf PORTA, SpeakerOutput call waitGS3 decfsz playLoopCount, f ; see if we are done yet goto playGS3_loop ; no, loop some more return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; GS3 - (AF3) - 415 Hz - 2410 microsecond oscillations - 1205 microsecond flips waitGS3 movlw D'121' ; set up a count for this loop movwf waitCount ; save it into the variable call waitLoop return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; A3 - 440 Hz / 6 = 73.333 playA3 btfss PORTB, TempoInput goto playA3_SlowTempo goto playA3_FastTempo playA3_SlowTempo movlw D'73' ; set up a count for this loop movwf playLoopCount ; save it into the variable goto playA3_loop playA3_FastTempo movlw D'37' ; set up a count for this loop movwf playLoopCount ; save it into the variable playA3_loop bcf PORTA, SpeakerOutput call waitA3 bsf PORTA, SpeakerOutput call waitA3 decfsz playLoopCount, f ; see if we are done yet goto playA3_loop ; no, loop some more return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; A3 - 440 Hz - 2272 microsecond oscillations - 1136 microsecond flips waitA3 movlw D'114' ; set up a count for this loop movwf waitCount ; save it into the variable call waitLoop return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; AS3 - BF3 - 466 Hz / 6 = 77.666 playAS3 playBF3 btfss PORTB, TempoInput goto playAS3_SlowTempo goto playAS3_FastTempo playAS3_SlowTempo movlw D'78' ; set up a count for this loop movwf playLoopCount ; save it into the variable goto playAS3_loop playAS3_FastTempo movlw D'39' ; set up a count for this loop movwf playLoopCount ; save it into the variable playAS3_loop bcf PORTA, SpeakerOutput call waitAS3 bsf PORTA, SpeakerOutput call waitAS3 decfsz playLoopCount, f ; see if we are done yet goto playAS3_loop ; no, loop some more return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; AS3 - (BF3) - 466 Hz - 2146 microsecond oscillations - 1073 microsecond flips waitAS3 movlw D'107' ; set up a count for this loop movwf waitCount ; save it into the variable call waitLoop return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; B3 - 495 Hz / 6 = 82.5 playB3 btfss PORTB, TempoInput goto playB3_SlowTempo goto playB3_FastTempo playB3_SlowTempo movlw D'83' ; set up a count for this loop movwf playLoopCount ; save it into the variable goto playB3_loop playB3_FastTempo movlw D'41' ; set up a count for this loop movwf playLoopCount ; save it into the variable playB3_loop bcf PORTA, SpeakerOutput call waitB3 bsf PORTA, SpeakerOutput call waitB3 decfsz playLoopCount, f ; see if we are done yet goto playB3_loop ; no, loop some more return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; B3 - 495 Hz - 2020 microsecond oscillations - 1010 microsecond flips waitB3 movlw D'101' ; set up a count for this loop movwf waitCount ; save it into the variable call waitLoop return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; C4 - 524 Hz / 6 = 87.333 playC4 btfss PORTB, TempoInput goto playC4_SlowTempo goto playC4_FastTempo playC4_SlowTempo movlw D'87' ; set up a count for this loop movwf playLoopCount ; save it into the variable goto playC4_loop playC4_FastTempo movlw D'44' ; set up a count for this loop movwf playLoopCount ; save it into the variable playC4_loop bcf PORTA, SpeakerOutput call waitC4 bsf PORTA, SpeakerOutput call waitC4 decfsz playLoopCount, f ; see if we are done yet goto playC4_loop ; no, loop some more return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; C4 - 524 Hz - 1908 microsecond oscillations - 954 microsecond flips waitC4 movlw D'95' ; set up a count for this loop movwf waitCount ; save it into the variable call waitLoop return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; CS4 - DF4 - 554 Hz / 6 = 92.333 playCS4 playDF4 btfss PORTB, TempoInput goto playCS4_SlowTempo goto playCS4_FastTempo playCS4_SlowTempo movlw D'92' ; set up a count for this loop movwf playLoopCount ; save it into the variable goto playCS4_loop playCS4_FastTempo movlw D'46' ; set up a count for this loop movwf playLoopCount ; save it into the variable playCS4_loop bcf PORTA, SpeakerOutput call waitCS4 bsf PORTA, SpeakerOutput call waitCS4 decfsz playLoopCount, f ; see if we are done yet goto playCS4_loop ; no, loop some more return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; CS4 - (DF4) - 554 Hz - 1806 microsecond oscillations - 903 microsecond flips waitCS4 movlw D'90' ; set up a count for this loop movwf waitCount ; save it into the variable call waitLoop return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; D4 - 588 Hz / 6 = 98 playD4 btfss PORTB, TempoInput goto playD4_SlowTempo goto playD4_FastTempo playD4_SlowTempo movlw D'98' ; set up a count for this loop movwf playLoopCount ; save it into the variable goto playD4_loop playD4_FastTempo movlw D'49' ; set up a count for this loop movwf playLoopCount ; save it into the variable playD4_loop bcf PORTA, SpeakerOutput call waitD4 bsf PORTA, SpeakerOutput call waitD4 decfsz playLoopCount, f ; see if we are done yet goto playD4_loop ; no, loop some more return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; D4 - 588 Hz - 1700 microsecond oscillations - 850 microsecond flips waitD4 movlw D'85' ; set up a count for this loop movwf waitCount ; save it into the variable call waitLoop return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; DS4 - EF4 - 622 Hz / 6 = 103.666 playDS4 playEF4 btfss PORTB, TempoInput goto playDS4_SlowTempo goto playDS4_FastTempo playDS4_SlowTempo movlw D'104' ; set up a count for this loop movwf playLoopCount ; save it into the variable goto playDS4_loop playDS4_FastTempo movlw D'52' ; set up a count for this loop movwf playLoopCount ; save it into the variable playDS4_loop bcf PORTA, SpeakerOutput call waitDS4 bsf PORTA, SpeakerOutput call waitDS4 decfsz playLoopCount, f ; see if we are done yet goto playDS4_loop ; no, loop some more return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; DS4 - (EF4) - 622 Hz - 1608 microsecond oscillations - 804 microsecond flips waitDS4 movlw D'80' ; set up a count for this loop movwf waitCount ; save it into the variable call waitLoop return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; E4 - 660 Hz / 6 = 110 playE4 btfss PORTB, TempoInput goto playE4_SlowTempo goto playE4_FastTempo playE4_SlowTempo movlw D'110' ; set up a count for this loop movwf playLoopCount ; save it into the variable goto playE4_loop playE4_FastTempo movlw D'55' ; set up a count for this loop movwf playLoopCount ; save it into the variable playE4_loop bcf PORTA, SpeakerOutput call waitE4 bsf PORTA, SpeakerOutput call waitE4 decfsz playLoopCount, f ; see if we are done yet goto playE4_loop ; no, loop some more return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; E4 - 660 Hz - 1516 microsecond oscillations - 758 microsecond flips waitE4 movlw D'76' ; set up a count for this loop movwf waitCount ; save it into the variable call waitLoop return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; F4 - 698 Hz / 6 = 116.333 playF4 btfss PORTB, TempoInput goto playF4_SlowTempo goto playF4_FastTempo playF4_SlowTempo movlw D'116' ; set up a count for this loop movwf playLoopCount ; save it into the variable goto playF4_loop playF4_FastTempo movlw D'58' ; set up a count for this loop movwf playLoopCount ; save it into the variable playF4_loop bcf PORTA, SpeakerOutput call waitF4 bsf PORTA, SpeakerOutput call waitF4 decfsz playLoopCount, f ; see if we are done yet goto playF4_loop ; no, loop some more return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; F4 - 698 Hz - 1432 microsecond oscillations - 716 microsecond flips waitF4 movlw D'72' ; set up a count for this loop movwf waitCount ; save it into the variable call waitLoop return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; FS4 - GF4 - 740 Hz / 6 = 123.333 playFS4 playGF4 btfss PORTB, TempoInput goto playFS4_SlowTempo goto playFS4_FastTempo playFS4_SlowTempo movlw D'123' ; set up a count for this loop movwf playLoopCount ; save it into the variable goto playFS4_loop playFS4_FastTempo movlw D'61' ; set up a count for this loop movwf playLoopCount ; save it into the variable playFS4_loop bcf PORTA, SpeakerOutput call waitFS4 bsf PORTA, SpeakerOutput call waitFS4 decfsz playLoopCount, f ; see if we are done yet goto playFS4_loop ; no, loop some more return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; FS4 - (GF4) - 740 Hz - 1352 microsecond oscillations - 676 microsecond flips waitFS4 movlw D'68' ; set up a count for this loop movwf waitCount ; save it into the variable call waitLoop return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; G4 - 784 Hz / 6 = 130.666 playG4 btfss PORTB, TempoInput goto playG4_SlowTempo goto playG4_FastTempo playG4_SlowTempo movlw D'130' ; set up a count for this loop movwf playLoopCount ; save it into the variable goto playG4_loop playG4_FastTempo movlw D'65' ; set up a count for this loop movwf playLoopCount ; save it into the variable playG4_loop bcf PORTA, SpeakerOutput call waitG4 bsf PORTA, SpeakerOutput call waitG4 decfsz playLoopCount, f ; see if we are done yet goto playG4_loop ; no, loop some more return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; G4 - 784 Hz - 1276 microsecond oscillations - 638 microsecond flips waitG4 movlw D'63' ; set up a count for this loop movwf waitCount ; save it into the variable call waitLoop return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; GS4 - AF4 - 830 Hz / 6 = 138.333 playGS4 playAF4 btfss PORTB, TempoInput goto playGS4_SlowTempo goto playGS4_FastTempo playGS4_SlowTempo movlw D'138' ; set up a count for this loop movwf playLoopCount ; save it into the variable goto playGS4_loop playGS4_FastTempo movlw D'69' ; set up a count for this loop movwf playLoopCount ; save it into the variable playGS4_loop bcf PORTA, SpeakerOutput call waitGS4 bsf PORTA, SpeakerOutput call waitGS4 decfsz playLoopCount, f ; see if we are done yet goto playGS4_loop ; no, loop some more return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; GS4 - (AF4) - 830 Hz - 1204 microsecond oscillations - 602 microsecond flips waitGS4 movlw D'60' ; set up a count for this loop movwf waitCount ; save it into the variable call waitLoop return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; A4 - 880 Hz / 6 = 146.666 playA4 btfss PORTB, TempoInput goto playA4_SlowTempo goto playA4_FastTempo playA4_SlowTempo movlw D'147' ; set up a count for this loop movwf playLoopCount ; save it into the variable goto playA4_loop playA4_FastTempo movlw D'73' ; set up a count for this loop movwf playLoopCount ; save it into the variable playA4_loop bcf PORTA, SpeakerOutput call waitA4 bsf PORTA, SpeakerOutput call waitA4 decfsz playLoopCount, f ; see if we are done yet goto playA4_loop ; no, loop some more return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; A4 - 880 Hz - 1136 microsecond oscillations - 568 microsecond flips waitA4 movlw D'57' ; set up a count for this loop movwf waitCount ; save it into the variable call waitLoop return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; AS4 - BF4 - 932 Hz / 6 = 155.333 playAS4 playBF4 btfss PORTB, TempoInput goto playAS4_SlowTempo goto playAS4_FastTempo playAS4_SlowTempo movlw D'155' ; set up a count for this loop movwf playLoopCount ; save it into the variable goto playAS4_loop playAS4_FastTempo movlw D'78' ; set up a count for this loop movwf playLoopCount ; save it into the variable playAS4_loop bcf PORTA, SpeakerOutput call waitAS4 bsf PORTA, SpeakerOutput call waitAS4 decfsz playLoopCount, f ; see if we are done yet goto playAS4_loop ; no, loop some more return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; AS4 - (BF4) - 932 Hz - 1072 microsecond oscillations - 536 microsecond flips waitAS4 movlw D'54' ; set up a count for this loop movwf waitCount ; save it into the variable call waitLoop return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; B4 - 990 Hz / 6 = 165 playB4 btfss PORTB, TempoInput goto playB4_SlowTempo goto playB4_FastTempo playB4_SlowTempo movlw D'165' ; set up a count for this loop movwf playLoopCount ; save it into the variable goto playB4_loop playB4_FastTempo movlw D'83' ; set up a count for this loop movwf playLoopCount ; save it into the variable playB4_loop bcf PORTA, SpeakerOutput call waitB4 bsf PORTA, SpeakerOutput call waitB4 decfsz playLoopCount, f ; see if we are done yet goto playB4_loop ; no, loop some more return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; B4 - 990 Hz - 1010 microsecond oscillations - 505 microsecond flips waitB4 movlw D'51' ; set up a count for this loop movwf waitCount ; save it into the variable call waitLoop return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; waitLoop is used to complete the above wait functions ; precondition: the number of loops (1 loop = 1 microsecond = 10 instructions) ; to wait must be stored in waitCount waitLoop nop ; delay by one instruction nop nop nop nop nop nop decfsz waitCount, f ; see if we are done yet goto waitLoop ; no, loop some more return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; end of all code end