Hi.. ang project ko po is using gsm interfaced with pic16f877a micocontroller. ngayon eto un program na huli ko na try, ang prob ko is hindi ko maopen ung text message sa gsm module para icompare iyon sa delim na naka set. At pagna open ng gsm un sms na sinend eh may matrigger na ports pra mag ON. sana po matulungan nyo po ako.
program GSM
symbol CR = 13 ' Carriage Return (enter key)
Symbol CTRL_Z = 26 ' Control + Z key
symbol LF = 10 ' linefeed
symbol quote = 34 ' ascii code for quote (")
dim delim as string[20]
dim count, tym as byte
dim txt as string[10]
trisa=%000000
trisb=%00000000
main:
Usart_Init(9600)
porta=%000000
portb=%00000000
delay_ms(400)
gosub check_connection
gosub text_mode
portb.1=1
gosub readstring
portb.2=1
delim = "on1"
porta=%000000
portb=%00000000
while TRUE
if Usart_Data_Ready() = 1 then
Usart_Read_Text(txt,delim)
delay_ms(400)
porta.0=1
delay_ms(400)
end if
wend
check_connection:
' This will check the availability of GSM module
count = 0
while count < 5 'To make sure GSM communicate perfectly
Usart_Write_Text("AT") 'AT commands of gsm module
delay_ms(500)
usart_write(CR)
delay_ms(500)
portb.0=1
count = count + 1
wend
return
text_mode:
'
' This will instruct the phone to use text mode.
' Mikrobasic cannot send the whole command "AT+cmgf=1", so
' the command is sent by chunk "AT","+",and "cmgf=1"
'
Usart_Write_Text("AT")
delay_ms(500)
Usart_Write_Text("+")
delay_ms(4000)
Usart_Write_Text("CMGF=1")
delay_ms(500)
usart_write(CR)
delay_ms(500)
return
readstring:
tym=0
while tym < 20
portb.3 = 1
Usart_Write_Text("AT")
delay_ms(500)
Usart_Write_Text("+")
delay_ms(4000)
Usart_Write_Text("CMGR=1")
delay_ms(500)
usart_write(CR)
delay_ms(500)
portb.3 = 0
tym=tym+1
wend
return
goto main
end.