For starters I would suggest to use crystal at 8MHz or better at 16MHz EXACTLY. Not 4.5 or other. May be 4MHz would work, but don't recommend it. Too slow. It is important to have correct frequency, otherwise the UART will be out of sync.
Then use these Defines
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 24h '9600 baud rate, BRGH=1
DEFINE HSER_BAUD 9600
DEFINE HSER_SPBRG 129
DEFINE HSER_CLROERR 1
DEFINE OSC 8 'or 16
What are you trying to do here?
this makes the A port input :trisa = %11111111 'set portA-RA1 input
and this makes the port output (?): porta = %00000000 'set portA high to give an input sensor
Then I see at your code that you send a ATZ to the mobile. Have you checked how long does it take for a mobile to RESET? I found that the Wavecom needs about 17 seconds for the GSM engine to be accessible. In the meantime the AT commands are working OK!!!
First you have to check if the mobile is responding with its name like this:
HSerout ["AT+CGMI",13] 'Get Manufacturer ID
Hserin 1500,err1,[wait("WAV")] 'Wait for Wavecom Module <<<--- Put here the name of your modem!!!
lcdout com,line1,"Module found!"
One trick to succesfully realize that you can send SMS is to check if at the command AT+CMGF=1 the device responds with OK like this:
HSerout ["AT+CMGF=1",13] 'Text SMS mode
HSerin 5000,error,[wait("OK")]
The devices have different respond times for different commands.
You have to check with a terminal programm like Hyperterminal sending AT+ commands. Also always wait for a response from the mobile. Either OK or another character.
Ioannis
Bookmarks