#include <p16c745.inc> ; include the defaults for the chip
org 0x00000020
Start
bsf status, RP0 ; select bank 1
clrf PORTB ; clear PORTB output latch
clrf PORTA ; Clear PORTA output latch
movlw b'00000000' ; Set all pins PORTB as output
movwf TRISB
bcf STATUS, RP0 ; go to bank 0
ON
btfsc PORTA,4 ; Is GSM output ON?
goto ON ; No, go back check again
bsf PORTB,0 ; turn on RB0 (LED) only!
; RTC will start counting 1hr
;----------------After RTC finish counting 1hr------------
Start1
bsf STATUS,RP0 ;select bank 1
clrf PORTA ; clear PORTA output latch
movlw b'00010000' ; Set RA4 as Input port,and the rest as output
movwf TRISA
bcf STATUS, RP0 ; go to bank 0
bsf PORTA,3 ; Set RA3 and Send signal '1' to modem input
;-----------------Application turn off--------------------
DebounceA
btfss PORTA,4 ; Is Modem output OFF?
goto DebounceA ; No, wait somemore
OFF
bcf PORTB,0 ; Turn off RB0 (LED) only
Start2
bcf PORTA,3 ; Clr RA3 and Send signal "0" to Modem input
goto Start
end