;Period = (PR2+1)*4*Tosc*PS TMR2
;Period = 30uS--->33Khz
INIT_PWM bcf STATUS,RP0 ; B0
clrf INTCON
clrf CCP1CON
bsf STATUS,RP0 ; B1
movlw .29 ; 30uS Period
movwf PR2
bcf STATUS,RP0 ; B0
movlw b'00000110' ; 20% duty cycle
movwf CCPR1L
movlw b'00000100' ; T2 = ON,PS = 1:1
movwf T2CON
movlw b'00001100' ; PWM Mode,
movwf CCP1CON
; ;
INIT_TMR0 bsf STATUS,RP0 ; B1
movlw b'00000100' ; PS = 1:32
movwf OPTION_REG
bcf STATUS,RP0 ; B0
movlw b'00100000' ; GIE = OFF,T0IE = ON
movwf INTCON
;
clrf Flag_Register
movlw .40
movwf Display_Counter
;===========================================================
Check_State btfss Flag_Register,Input
goto Reset_TMR0
btfss INTCON,T0IF
goto TX_Loop
bcf INTCON,T0IF
decfsz Timer_Counter,F ; count 1S time "256 X 32 X 100 = 0.8S"
goto TX_Loop
bsf GPIO,GP0 ; turn on relay
movlw .100
movwf Timer_Counter
;
TX_Loop movlw b'00000000' ; Off Signal
movwf CCPR1L
call Del_600uS ; //
movlw b'00000110' ; 20% duty cycle
movwf CCPR1L
call Del_600uS ; //
bsf Flag_Register,Input
movf GPIO,W
andlw b'00100000' ; check GP5 IR module
btfsc STATUS,Z
bcf Flag_Register,Input ;
;
decfsz Display_Counter,F
goto Check_State
movlw .40
movwf Display_Counter
Show_Display btfss Flag_Register,Input ; show display
goto Turn_OFF_LED
Turn_ON_LED bsf GPIO,GP1
goto Check_State
Turn_OFF_LED bcf GPIO,GP1
goto Check_State
Reset_TMR0 clrf TMR0
movlw .100
movwf Timer_Counter
bcf GPIO,GP0 ; turn off relay
goto TX_Loop
Del_600uS movlw .200
movwf Counter
Del_600uS_Loop decfsz Counter,F
goto $-1
return
end ; directive 'end of program'