LIST P=PIC12F629 INCLUDE P12F629.INC __CONFIG _INTRC_OSC_NOCLKOUT & _PWRTE_ON & _WDT_OFF & _BODEN_OFF & _MCLRE_OFF ;***************_int_register_************************************** time equ H'20' cnt1 equ H'21' cnt2 equ H'22' cnt3 equ H'23' cnt4 equ H'24' cnt_pwm equ H'25' cnt_off equ H'26' temp equ H'27' width equ H'28' cntRep equ H'29' ;******************************************************************* org H'00' goto SETUP ;***************_warikomi_****************************************** org H'04' retfie ;***************_setup_********************************************* SETUP bsf STATUS,RP0 call H'3ff' movwf OSCCAL movlw B'00000000' ;all_output movwf TRISIO movlw B'00000000' ;pulup_enable movwf OPTION_REG bcf STATUS,RP0 clrf GPIO movlw B'00000111' ;dejital I/O movwf CMCON movlw D'50' ;set width movwf width ;***************Main*************************** MAIN ;max width-1 movlw D'2' movwf cntRep BREATH movlw D'5' call PWM movlw D'5' call PWM movlw D'5' call PWM movlw D'5' call PWM movlw D'6' call PWM movlw D'7' call PWM movlw D'8' call PWM movlw D'9' call PWM movlw D'10' call PWM movlw D'11' call PWM movlw D'12' call PWM movlw D'15' call PWM movlw D'18' call PWM movlw D'20' call PWM movlw D'22' call PWM movlw D'24' call PWM movlw D'28' call PWM movlw D'30' call PWM movlw D'34' call PWM movlw D'36' call PWM movlw D'38' call PWM movlw D'40' call PWM movlw D'42' call PWM movlw D'44' call PWM movlw D'46' call PWM movlw D'47' call PWM movlw D'49' call PWM movlw D'49' call PWM movlw D'49' call PWM movlw D'49' call PWM movlw D'49' call PWM movlw D'49' call PWM movlw D'49' call PWM movlw D'47' call PWM movlw D'46' call PWM movlw D'44' call PWM movlw D'42' call PWM movlw D'40' call PWM movlw D'38' call PWM movlw D'36' call PWM movlw D'34' call PWM movlw D'30' call PWM movlw D'28' call PWM movlw D'24' call PWM movlw D'22' call PWM movlw D'20' call PWM movlw D'18' call PWM movlw D'15' call PWM movlw D'12' call PWM movlw D'11' call PWM movlw D'10' call PWM movlw D'9' call PWM movlw D'8' call PWM movlw D'7' call PWM movlw D'6' call PWM movlw D'5' call PWM movlw D'5' call PWM movlw D'5' call PWM movlw D'5' call PWM call PWM_WAIT call PWM_WAIT call PWM_WAIT decfsz cntRep goto BREATH movlw D'10' movwf cntRep BEAT movlw D'5' call PWM movlw D'7' call PWM movlw D'10' call PWM movlw D'14' call PWM movlw D'35' call PWM movlw D'42' call PWM movlw D'49' call PWM movlw D'49' call PWM movlw D'42' call PWM movlw D'30' call PWM movlw D'20' call PWM movlw D'25' call PWM movlw D'30' call PWM movlw D'35' call PWM movlw D'35' call PWM movlw D'30' call PWM movlw D'25' call PWM movlw D'20' call PWM movlw D'15' call PWM movlw D'10' call PWM movlw D'7' call PWM call PWM_WAIT ;call PWM_WAIT ;call PWM_WAIT decfsz cntRep goto BEAT goto MAIN ;**************pwm*********************** PWM movwf temp movlw D'256' movwf time WIDTH movf temp,0 movwf cnt_pwm movf width,0 ;movlw D'100' movwf cnt_off movf temp,0 subwf cnt_off,1 bsf GPIO,1 WAIT_ON decfsz cnt_pwm goto WAIT_ON bcf GPIO,1 call WAIT_OFF decfsz time,1 goto WIDTH return ;***************wait_off_time********** WAIT_OFF decfsz cnt_off goto WAIT_OFF return ;****************wait_and_pwm************************************* PWM_WAIT movlw D'255' ;set width movwf width movlw D'20' call PWM movlw D'20' call PWM movlw D'50' movwf width return ;******************_1ms_******************************************* WAIT1M movlw D'256' movwf cnt1 TIMLP1 nop decfsz cnt1,1 goto TIMLP1 nop return ;******************_10ms_(10.036ms)********************************** WAIT10M movlw D'10' movwf cnt2 TIMLP2 call WAIT1M decfsz cnt2,1 goto TIMLP2 return ;******************_50ms_(50.156ms)********************************** WAIT50M movlw D'50' movwf cnt3 TIMLP3 call WAIT1M decfsz cnt3,1 goto TIMLP3 return ;*******************_1s_(1.000755)*********************************** WAIT1S movlw D'250' movwf cnt4 TIMLP4 call WAIT1M call WAIT1M call WAIT1M call WAIT1M decfsz cnt4,1 goto TIMLP4 return ;**********************_kousei_************************************* org H'3ff' retlw H'48' end