I received a PM defining the problem a little better:
dear sir
can u help me this project
my modem ok
send AT
reply OK
this program send sms repitly how to stop it
thank you
So, you only want to send sms on change of state for portd.0 or portd.1 ?
Here are some untested modifications to your code. It should test for a change condition on portd.0 and portd.1. I know you said you only wanted d.0, but you can always remove the rest.
Code:
TRISB=%00000000
PORTB=%00000000
DEFINE OSC 4
DEFINE HSER_TXSTA 20h
DEFINE HSER_RCSTA 90h
DEFINE HSER_BAUD 2400
DEFINE HSER_SPBRG 25
DEFINE HSER_CLROERR 1
PortDStatus var byte ' variable for storing status of portd
TRISB=%00000000
PORTB=%00000000
trisd=%00001111
portd=%00000000
GSM_CHECK:
portb=%11110000
HSEROUT ["AT",13]
HSERIN 5000, GSM_CHECK, [WAIT("OK")]
pause 200
PORTb=%00000000
'get initial status
PortDStatus.0 = PORTD.0
PortDStatus.1 = PORTD.1
BEGIN:
high PORTB.6
if PORTD.0 != PortDStatus.0 then 'sensed change in PORTD.0
pause 10 'debounce 10 ms
PortDStatus.0 = PORTD.0 'save new status for PORTD.0
if PORTD.0 = 1 then
gosub SEND_SMS0 'send new status report
else 'PORTD.0 = 0
gosub SEND_SMS2
endif
endif
if PORTD.1 != PortDStatus.1 then 'sensed change in PORTD.1
pause 10
PortDStatus.1 = PORTD.1 'save new status for PORTD.1
IF PORTD.1 = 1 then
gosub SEND_SMS1
else 'PORTD.1 = 0
gosub SEND_SMS3
endif
endif
PAUSE 1000
LOW PORTB.6
GOTO BEGIN
SEND_SMS0:
HIGH PORTB.7
HSEROUT ["at+cmgs=",34,"0719099xxx",34,13]
PAUSE 1000
HSEROUT ["unit ,1, triped",26]
HSERIN 5000, BEGIN, [WAIT("OK")]
LOW PORTB.7
return
SEND_SMS1:
HIGH PORTB.6
HSEROUT ["at+cmgs=",34,"0719099xxx",34,13]
PAUSE 1000
HSEROUT ["unit,2, triped",26]
HSERIN 5000, BEGIN, [WAIT("OK")]
LOW PORTB.6
return
SEND_SMS2:
HIGH PORTB.5
HSEROUT ["at+cmgs=",34,"0719099xxx",34,13]
PAUSE 1000
HSEROUT ["unit ,1, syncronus",26]
HSERIN 5000, BEGIN, [WAIT("OK")]
LOW PORTB.5
return
SEND_SMS3:
HIGH PORTB.4
HSEROUT ["at+cmgs=",34,"0719099xxx",34,13]
PAUSE 1000
HSEROUT ["unit ,2,syncronus",26]
HSERIN 5000, BEGIN, [WAIT("OK")]
LOW PORTB.4
return
end
Bookmarks