;****************************************************************************************** ; Project : ; Program Name : ; Programer : ; Create date : Version 1.0 H21.06.10 ; History : ;****************************************************************************************** ; Description ; 平均律音階 ; 中心の“ラ”の音の周波数が440Hz,その1オクターブ低い“ラ”の音が220Hz ; 音階の周波数=220×2^(n/12) nは,1から12の整数 ; ド :261.63Hz(96回) 26 ; レ :293.66Hz(85回) 29 ; ミ :329.63Hz(76回) 33 ; ファ:349.23Hz(72回) 35 ; ソ :392 Hz(64回) 39 ; ラ :440 Hz(57回) 44 ; シ :493.88Hz(51回) 49 ; ド :523.25Hz(48回) 52 ; ; PIC12F629:Precision Internal 4 MHz oscillator factory calibrated to ±1% ;****************************************************************************************** LIST P=PIC12F629 ; INCLUDE "P12F629.inc" ;標準ヘッダ定義ファイル __CONFIG _CPD_OFF & _CP_OFF & _BODEN_OFF & _MCLRE_OFF & _PWRTE_OFF & _WDT_OFF & _INTRC_OSC_NOCLKOUT ; LP0 EQU 20H LP1 EQU 21H LP2 EQU 22H LP3 EQU 23H LP_N EQU 24H LP_M EQU 25H ; DO_N EQU D'96' DO_M EQU D'26' RE_N EQU D'85' RE_M EQU D'29' MI_N EQU D'76' MI_M EQU D'33' FA_N EQU D'72' FA_M EQU D'35' SO_N EQU D'64' SO_M EQU D'39' RA_N EQU D'57' RA_M EQU D'44' SI_N EQU D'51' SI_M EQU D'49' DO1_N EQU D'48' DO1_M EQU D'52' SPEED_1 EQU D'01' ; ORG 0 GOTO START ORG 4 GOTO START START BCF STATUS,RP0 MOVLW 07H MOVWF CMCON ; BANK0でCOMPARATOR_I/OをデジタルIO設定 CLRF GPIO ; BANK0でポート初期化 BSF STATUS,RP0 MOVLW B'111011' MOVWF TRISIO ; BANK1でPORT設定 MOVLW B'10000000' MOVWF OSCCAL ; BANK1で内臓OSC4MHz(PIC12F629のInt_OSC最高速度)を設定 BCF STATUS,RP0 ; MAIN ; ************************************** ; 音楽1 ; ************************************** MAIN_MU1 MOVLW DO_M MOVWF LP_M MOVLW DO_N MOVWF LP_N CALL PLAYWB CALL STOPWB MOVLW DO_M MOVWF LP_M MOVLW DO_N MOVWF LP_N CALL PLAYWB CALL STOPWB MOVLW RE_M MOVWF LP_M MOVLW RE_N MOVWF LP_N CALL PLAYWB CALL STOPWB MOVLW RE_M MOVWF LP_M MOVLW RE_N MOVWF LP_N CALL PLAYWB CALL STOPWB MOVLW MI_M MOVWF LP_M MOVLW MI_N MOVWF LP_N CALL PLAYWB CALL STOPWB MOVLW MI_M MOVWF LP_M MOVLW MI_N MOVWF LP_N CALL PLAYWB CALL STOPWB MOVLW RE_M MOVWF LP_M MOVLW RE_N MOVWF LP_N CALL PLAYWB CALL PLAYWB CALL PLAYWB CALL PLAYWB CALL STOPWB CALL STOPWB ; MOVLW MI_M MOVWF LP_M MOVLW MI_N MOVWF LP_N CALL PLAYWB CALL STOPWB MOVLW MI_M MOVWF LP_M MOVLW MI_N MOVWF LP_N CALL PLAYWB CALL STOPWB MOVLW SO_M MOVWF LP_M MOVLW SO_N MOVWF LP_N CALL PLAYWB CALL STOPWB MOVLW SO_M MOVWF LP_M MOVLW SO_N MOVWF LP_N CALL PLAYWB CALL STOPWB MOVLW RA_M MOVWF LP_M MOVLW RA_N MOVWF LP_N CALL PLAYWB CALL STOPWB MOVLW SO_M MOVWF LP_M MOVLW SO_N MOVWF LP_N CALL PLAYWB CALL STOPWB MOVLW SO_M MOVWF LP_M MOVLW SO_N MOVWF LP_N CALL PLAYWB CALL PLAYWB CALL PLAYWB CALL PLAYWB CALL STOPWB CALL STOPWB ; MOVLW RA_M MOVWF LP_M MOVLW RA_N MOVWF LP_N CALL PLAYWB CALL STOPWB MOVLW RA_M MOVWF LP_M MOVLW RA_N MOVWF LP_N CALL PLAYWB CALL STOPWB MOVLW SO_M MOVWF LP_M MOVLW SO_N MOVWF LP_N CALL PLAYWB CALL STOPWB MOVLW SO_M MOVWF LP_M MOVLW SO_N MOVWF LP_N CALL PLAYWB CALL STOPWB MOVLW MI_M MOVWF LP_M MOVLW MI_N MOVWF LP_N CALL PLAYWB CALL STOPWB MOVLW DO_M MOVWF LP_M MOVLW DO_N MOVWF LP_N CALL PLAYWB CALL STOPWB MOVLW RE_M MOVWF LP_M MOVLW RE_N MOVWF LP_N CALL PLAYWB CALL PLAYWB CALL PLAYWB CALL PLAYWB CALL STOPWB CALL STOPWB ; MOVLW SO_M MOVWF LP_M MOVLW SO_N MOVWF LP_N CALL PLAYWB CALL STOPWB MOVLW SO_M MOVWF LP_M MOVLW SO_N MOVWF LP_N CALL PLAYWB CALL STOPWB MOVLW MI_M MOVWF LP_M MOVLW MI_N MOVWF LP_N CALL PLAYWB CALL STOPWB MOVLW DO_M MOVWF LP_M MOVLW DO_N MOVWF LP_N CALL PLAYWB CALL STOPWB MOVLW RE_M MOVWF LP_M MOVLW RE_N MOVWF LP_N CALL PLAYWB CALL STOPWB MOVLW MI_M MOVWF LP_M MOVLW MI_N MOVWF LP_N CALL PLAYWB CALL STOPWB MOVLW DO_M MOVWF LP_M MOVLW DO_N MOVWF LP_N CALL PLAYWB CALL PLAYWB CALL PLAYWB CALL PLAYWB CALL STOPWB CALL STOPWB ;; CALL STOPWB CALL STOPWB CALL STOPWB CALL STOPWB CALL STOPWB CALL STOPWB GOTO MAIN ;****************************************************************************************** ; Function Name : PLAYWB ; Title : ; Input : LP_M,LP_N ; Output : ; Description : ; Int_OSC(4MHz) : 4M/4 ==(20)==> 50KHz ==> (n)==> n Hz ;****************************************************************************************** PLAYWB ; (0)Play Time MOVFW LP_M MOVWF LP3 PLAY00 MOVLW SPEED_1 MOVWF LP2 PLAY01 ; (1)H_PLUS MOVLW B'000100' MOVWF GPIO MOVFW LP_N MOVWF LP1 PLAY01B MOVLW D'02' MOVWF LP0 PLAY01A NOP NOP ; NOP ; NOP ; NOP NOP NOP DECFSZ LP0,F GOTO PLAY01A DECFSZ LP1,F GOTO PLAY01B ; (2)L_PLUS MOVLW B'000000' MOVWF GPIO MOVFW LP_N MOVWF LP1 PLAY02B MOVLW D'02' MOVWF LP0 PLAY02A NOP NOP NOP NOP NOP NOP NOP DECFSZ LP0,F GOTO PLAY02A DECFSZ LP1,F GOTO PLAY02B DECFSZ LP2,F GOTO PLAY01 DECFSZ LP3,F GOTO PLAY00 RETLW H'00' ;****************************************************************************************** ; Function Name : STOPWB ; Title : ; Input : LP_M,LP_N ; Output : ; Description : ; Int_OSC(4MHz) : 4M/4 ==(20)==> 50KHz ==(100)==> 500Hz ==(100)==> 5Hz ;****************************************************************************************** STOPWB MOVLW B'000000' MOVWF GPIO ; (0)Stop Time MOVLW SPEED_1 MOVWF LP3 STOP00 MOVLW D'200' MOVWF LP2 STOP01 ; (1)L_PLUS MOVLW D'100' MOVWF LP1 STOP01B MOVLW D'02' MOVWF LP0 STOP01A NOP NOP ; NOP ; NOP ; NOP NOP NOP DECFSZ LP0,F GOTO STOP01A DECFSZ LP1,F GOTO STOP01B DECFSZ LP2,F GOTO STOP01 DECFSZ LP3,F GOTO STOP00 RETLW H'00' END