PDA

View Full Version : Pic18F4550 + SIMCOM SIM900D GSM/GPRS



tacbanon
- 14th July 2012, 00:16
Hello to everyone,
I have a SIMCOM SIM900D GSM/GPRS module. I'm trying to make it communicate with the Pic18F4550 with 20Mhz crystal. But before that I made sure that the module is working/replying to AT commands by connecting it the serial port communicator via USB - TTL converter. And I confirmed that PC(Serial communicator) -> USB-TTL converter + GSM(Baud 115200) module are working.
6585

Then the next step I did is to try to send HSEROUT ["AT",13] to the GSM module..using hardware setup below
6586
and this is the code I'm using...



asm
__CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
__CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
__CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L & _BORV_2_2L & _VREGEN_ON_2L
__CONFIG _CONFIG2H, _WDT_OFF_2H
__CONFIG _CONFIG3H, _MCLRE_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_ON_3H
__CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _ICPRT_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L
endasm


DEFINE OSC 48
DEFINE HSER_RCSTA 90h ' enable serial port,
DEFINE HSER_TXSTA 36 ' enable transmit, * we change 20h to 36 for 115200
DEFINE HSER_BAUD 115200
DEFINE HSER_CLOERR 1 ' automatic clear overrun error

TRISC = %10000000 ' PORTC.7 is the RX input, PORTC.6 is the TX output


' Serial communication definition
' ===============================
'
ADCON1 = %00001111 'Set up ADCON1 register no matter what you're doing!!!!!!
'::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::

INCLUDE "MODEDEFS.BAS" ' Include Shiftin/out modes


'************************************************* ****************************




Serialdata var byte

INTCON2.7 = 0 ' Enable PORTB pull-ups
TRISB = %11111000
TRISC = %10000000
led1 var PortC.0
TRISD = %00000000


Serout2 PORTD.5, 84, [$1B,$63,$30] 'cursor off for serial LCD
Serout2 PORTD.5, 84, [$1B,$45,"SMS DEBUG PORT"] ' serial LCD
main:
PORTB = 0 ' PORTB lines low to read buttons

If PORTB.4 = 0 Then ' If 1st button pressed...

HSEROUT ["Button 1",13]
Serout2 PORTD.5, 84, [$1B,$45, "SMS DEBUG PORT"]
Serout2 PORTD.5, 84, [$D, "Button 1 "]
pause 500
Serout2 PORTD.5, 84, [$1B,$45,"SMS DEBUG PORT"]
gosub GSM_CHECK
Endif
pause 200 ' pause to avoid sending repetation

goto main

End 'End program


GSM_CHECK:
HSEROUT ["AT",13] 'Send AT to modem followed by a CR
HSERIN 5000, GSM_CHECK_ERR, [WAIT("OK")] 'Check OK reply, wait 5sec max.
Serout2 PORTD.5, 84, [$D, "GSM OK"]
High PORTB.0 ' 1st LED on
PAUSE 1000
low PORTB.0
return

GSM_CHECK_ERR:
Serout2 PORTD.5, 84, [$D, "GSM ERROR"]

;HSEROUT ["GSM_ERROR",13]
Return




I tried to interchange C6 and C7 lines but still I'm not getting "OK" response...hope anyone can give a me hint what I'm missing in my setup.

Thanks in advance,
tacbanon

mackrackit
- 14th July 2012, 02:08
A quick guess. You need to invert the signal. Try a max232 in between??

tacbanon
- 14th July 2012, 02:37
A quick guess. You need to invert the signal. Try a max232 in between??
Hi mackrackit,
I did some more testing and the following codes works but still have some issues.



asm
__CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
__CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
__CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L & _BORV_2_2L & _VREGEN_ON_2L
__CONFIG _CONFIG2H, _WDT_OFF_2H
__CONFIG _CONFIG3H, _MCLRE_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_ON_3H
__CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _ICPRT_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L
endasm


DEFINE OSC 48
DEFINE HSER_RCSTA 90h ' enable serial port,
DEFINE HSER_TXSTA 36 ' enable transmit, * we change 20h to 36 for 115200
DEFINE HSER_BAUD 115200
DEFINE HSER_CLOERR 1 ' automatic clear overrun error

TRISC = %10000000 ' PORTC.7 is the RX input, PORTC.6 is the TX output


' Serial communication definition
' ===============================
'
ADCON1 = %00001111 'Set up ADCON1 register no matter what you're doing!!!!!!
'::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::

INCLUDE "MODEDEFS.BAS" ' Include Shiftin/out modes


'************************************************* ****************************

Serialdata var byte[25]

INTCON2.7 = 0 ' Enable PORTB pull-ups
TRISB = %11111000
TRISC = %10000000
led1 var PortC.0
TRISD = %00000000


Serout2 PORTD.5, 84, [$1B,$63,$30]
Serout2 PORTD.5, 84, [$1B,$45,"SMS DEBUG PORT"]
main:
PORTB = 0 ' PORTB lines low to read buttons
TRISB = %11111000
If PORTB.6 = 0 Then ' If 3rd button pressed...
PORTB.2 = 1 ' 3rd LED on
Serout2 PORTD.5, 84, [$1B,$45, "SMS DEBUG PORT"]
Serout2 PORTD.5, 84, [$D, "Button 3 "]
pause 500
Serout2 PORTD.5, 84, [$1B,$45,"SMS DEBUG PORT"]
GOSUB GSM_SIGCHECK
Endif

If PORTB.5 = 0 Then ' If 2nd button pressed...
PORTD.1 = 1 ' 2nd LED on
Serout2 PORTD.5, 84, [$1B,$45, "SMS DEBUG PORT"]
Serout2 PORTD.5, 84, [$D, "Button 2 "]
pause 500
Serout2 PORTD.5, 84, [$1B,$45,"SMS DEBUG PORT"]
gosub GSM_MODEL
Endif

pause 240 ' pause to avoid sending repetation


goto main
End 'End program

GSM_SIGCHECK:
HSEROUT ["AT+CSQ",13] 'Send AT to modem followed by a CR
HSERIN 4000, GSM_CHECK, [WAIT("AT+CSQ"),STR Serialdata\13] 'Check OK reply, wait 5sec max.
Serout2 PORTD.5, 84, [$D, STR Serialdata\13]
High PORTB.0 ' 1st LED on
PAUSE 1000
low PORTB.0
RETURN

GSM_CHECK_ERR:
Serout2 PORTD.5, 84, [$D, "GSM ERROR"]
Return

GSM_MODEL:
HSEROUT ["AT+CGMI",13] 'Ask model name
HSERIN 4000, GSM_MODEL, [WAIT("AT+CGMI"),STR Serialdata\13] 'Check model name "SIMCOM_Ltd"
Serout2 PORTD.5, 84, [$D, STR Serialdata\13]
High PORTB.0 ' 1st LED on
PAUSE 1000
low PORTB.0
return


After pressing each button (response displayed to the LCD) I need to press the RESET button of the LABX2 everytime.
What do you think its causing this?

Regards,
tacbanon

mackrackit
- 14th July 2012, 09:47
Again, just guessing..

Maybe the module is sending something but not what is expected.
Try moving the LED feed back to the beginning of the routine to see if it is stuck there.


GSM_SIGCHECK:
High PORTB.0 ' 1st LED on
PAUSE 1000
low PORTB.0
PAUSE 1000


HSEROUT ["AT+CSQ",13] 'Send AT to modem followed by a CR
HSERIN 4000, GSM_CHECK, [WAIT("AT+CSQ"),STR Serialdata\13] 'Check OK reply, wait 5sec max.
Serout2 PORTD.5, 84, [$D, STR Serialdata\13]
RETURN

tacbanon
- 14th July 2012, 11:43
Again, just guessing..

Maybe the module is sending something but not what is expected.
Try moving the LED feed back to the beginning of the routine to see if it is stuck there.


GSM_SIGCHECK:
High PORTB.0 ' 1st LED on
PAUSE 1000
low PORTB.0
PAUSE 1000


HSEROUT ["AT+CSQ",13] 'Send AT to modem followed by a CR
HSERIN 4000, GSM_CHECK, [WAIT("AT+CSQ"),STR Serialdata\13] 'Check OK reply, wait 5sec max.
Serout2 PORTD.5, 84, [$D, STR Serialdata\13]
RETURN


Hi macrackit,
Thanks for helping me out...but I still have the same issue. It works only once and needs to hit the RESET button in order to read incoming value.

Regards,
tacbanon

mackrackit
- 14th July 2012, 11:51
How far does it get before it locks up exactly?
Is it receiving the AT+CSQ ?

tacbanon
- 14th July 2012, 12:07
It locks up just right after it performs the first AT command..the same result when I rearrange the code.


main:
PORTB = 0 ' PORTB lines low to read buttons
TRISB = %11111000
;gosub CLR_SCRN
GOSUB GSM_SIGCHECK
;gosub CLR_SCRN
gosub GSM_MODEL

pause 260 ' pause to avoid sending repetition

;goto main
End 'End program


it perform GOSUB GSM_SIGCHECK then after it it never performs the gosub GSM_MODEL correctly and calls GSM_CHECK_ERR:
I also tried to interchange the sequence but the same results. It performs the GOSUB GSM_MODEL but failed to execute GOSUB GSM_SIGCHECK correctly.

/tacbanon

mackrackit
- 14th July 2012, 13:05
I do not see anyplace in the code in post#3 to call GSM_CHECK_ERR
And your last post has GOTO main commented out falling through to END.

Maybe with all of the trouble shooting there are other typos? Sorry that I can not spot the problem directly.

pedja089
- 14th July 2012, 13:41
Try
HSERIN [WAIT("CSQ: "),DEC Signal]
SEROUT2 ....[DEC Signal]
You don't have 13 chars, after AT+CSQ:...
From manual
STR ArrayVar\n{\c} Receive string of n characters optionally ended in character c
So If you want to string end after receiving CRLF
Try this
Serialdata var byte[4]
HSERIN 4000, GSM_CHECK, [WAIT("AT+CSQ"),STR Serialdata\4\13]

tacbanon
- 14th July 2012, 14:21
@pedja089
Thanks for the time helping..I tried the to call the following code below.


GSM_SIGCHECK:
High PORTB.0 ' 1st LED on
PAUSE 1000
low PORTB.0
PAUSE 1000
HSEROUT ["AT+CSQ",13] 'Send AT to modem followed by a CR
HSERIN 4000, GSM_CHECK_ERR, [WAIT("CSQ: "),DEC Signal]
SEROUT2 PORTD.5, 84,[$D,DEC Signal]

DEC Signal displays 14 which is I know it is correct. But when I try to call this block of code(pressing the 3rd button) 2nd time it calls GSM_CHECK_ERR...instead of 14. Works again if I press the RESET button.
What do you think it is causing this issue?

regards,
tacbanon

tacbanon
- 14th July 2012, 14:55
I do not see anyplace in the code in post#3 to call GSM_CHECK_ERR
And your last post has GOTO main commented out falling through to END.

Maybe with all of the trouble shooting there are other typos? Sorry that I can not spot the problem directly.

Sorry about that mackrackit...yeah I'm kinda dizzy now :)(been working on this since last night) below is the code what I was using.



asm
__CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
__CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
__CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L & _BORV_2_2L & _VREGEN_ON_2L
__CONFIG _CONFIG2H, _WDT_OFF_2H
__CONFIG _CONFIG3H, _MCLRE_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_ON_3H
__CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _ICPRT_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L
endasm


DEFINE OSC 48


DEFINE HSER_RCSTA 90h ' enable serial port,
DEFINE HSER_TXSTA 20h ' enable transmit, * we change 20h to 36 for 115200
DEFINE HSER_BAUD 9600
DEFINE HSER_CLOERR 1 ' automatic clear overrun error

TRISC = %10000000 ' PORTC.7 is the RX input, PORTC.6 is the TX output


' Serial communication definition
' ===============================
'
ADCON1 = %00001111 'Set up ADCON1 register no matter what you're doing!!!!!!
'::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::

INCLUDE "MODEDEFS.BAS" ' Include Shiftin/out modes


'************************************************* ****************************

Serialdata var byte[13]
INTCON2.7 = 0 ' Enable PORTB pull-ups

TRISB = %11111000
TRISC = %10000000
led1 var PortC.0
cntr var byte
cntr = 0
TRISD = %00000000


Serout2 PORTD.5, 84, [$1B,$63,$30]
gosub CLR_SCRN


main:
PORTB = 0 ' PORTB lines low to read buttons
TRISB = %11111000

If PORTB.6 = 0 Then ' If 3rd button pressed...
PORTB.2 = 1 ' 3rd LED on
gosub CLR_SCRN
Serout2 PORTD.5, 84, [$D, "Button 3 "]
pause 500
gosub CLR_SCRN
GOSUB GSM_SIGCHECK
Endif

If PORTB.5 = 0 Then ' If 2nd button pressed...
PORTD.1 = 1 ' 2nd LED on
gosub CLR_SCRN
Serout2 PORTD.5, 84, [$D, "Button 2 "]
pause 500
gosub CLR_SCRN
gosub GSM_MODEL
Endif

pause 260 ' pause to avoid sending repetation


goto main
End 'End program

GSM_SIGCHECK:
High PORTB.0 ' 1st LED on
PAUSE 1000
low PORTB.0
PAUSE 1000
HSEROUT ["AT+CSQ",13] 'Send AT to modem followed by a CR
HSERIN 4000, GSM_CHECK_ERR, [WAIT("AT+CSQ"),STR Serialdata\13]
Serout2 PORTD.5, 84, [$D, STR Serialdata\13]
RETURN

GSM_CHECK_ERR:
Serout2 PORTD.5, 84, [$D, "GSM ERROR"]

Return

GSM_MODEL:
High PORTB.0 ' 1st LED on
PAUSE 1000
low PORTB.0
PAUSE 1000
HSEROUT ["AT+CGMI",13] 'Ask model name
HSERIN 4000, GSM_CHECK_ERR, [WAIT("AT+CGMI"),STR Serialdata\13] 'Check model name "SIMCOM_Ltd"
Serout2 PORTD.5, 84, [$D, STR Serialdata\13]
return

CLR_SCRN:
cntr=cntr+1
Serout2 PORTD.5, 84, [$1B,$45,"GSM DEBUG PORT ",#cntr]
return


Thanks in advance,
tacbanon

tacbanon
- 14th July 2012, 15:05
Oops I also forgot to mention that I'm using 9600 baud rate, I thought it will change anything...:frown:

pedja089
- 14th July 2012, 15:30
Check does it send correctly with HT. Use your usb ttl uart converter board.
Try to send CRLF then pause 100, and then send command...

tacbanon
- 14th July 2012, 23:06
Check does it send correctly with HT. Use your usb ttl uart converter board.
Try to send CRLF then pause 100, and then send command...
On the SERIAL COMMUNICATORl, sending AT commands had no problems( w/ CR and CRLF).
6587

Regards,
tacbanon

tacbanon
- 14th July 2012, 23:42
I tried other serial communicator, and I'm not sure if I found the trouble...
6588
When I disable the Append New Line

6589
With New line after sending

Do you think adding new line after each send will solve it - how?



HSEROUT ["AT",13]
HSERIN 4000, GSM_CHECK_ERR, [WAIT("OK")]

The code above does not detect "OK".

regards,
tacbanon

pedja089
- 14th July 2012, 23:46
Try to connect PC to PIC, instead of modem...
Also use Rx on PC board to sniff what is happening when pic and modem communicate...

tacbanon
- 15th July 2012, 04:06
I tried to modify my hardware setup to detect whats going IN and OUT in the GSM module (below). I test each button(Button1-Button3) and each corresponding response of the GSM shown in the serial communicator.
6590

I noticed that everything seems normal..but when I tried the connection PIC-GSM... I have the same issue.
So sending PIC to GSM AT commands is not issue..I think when receiving incoming data from GSM to PIC is where the trouble is.

Regards,
tacbanon

tacbanon
- 15th July 2012, 05:53
I noticed that everything seems normal..but when I tried the connection PIC-GSM... I have the same issue.
What I meant was, when I set the entire connection between PIC-GSM I have the trouble again(need to press the reset button on my Labx2 devboard)

tacbanon
- 15th July 2012, 09:35
For testing I removed all HSERIN command to see if it will continue each line. And below is the results.
6591
Here is the code I'm using...



asm
__CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
__CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
__CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L & _BORV_2_2L & _VREGEN_ON_2L
__CONFIG _CONFIG2H, _WDT_OFF_2H
__CONFIG _CONFIG3H, _MCLRE_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_ON_3H
__CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _ICPRT_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L
endasm


DEFINE OSC 48


DEFINE HSER_RCSTA 90h ' enable serial port,
DEFINE HSER_TXSTA 20h ' enable transmit, * we change 20h to 36 for 115200
DEFINE HSER_BAUD 9600
DEFINE HSER_CLOERR 1 ' automatic clear overrun error

TRISC = %10000000 ' PORTC.7 is the RX input, PORTC.6 is the TX output


' Serial communication definition
' ===============================
'
ADCON1 = %00001111 'Set up ADCON1 register no matter what you're doing!!!!!!
'::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::

INCLUDE "MODEDEFS.BAS" ' Include Shiftin/out modes


'************************************************* ****************************


INTCON2.7 = 0 ' Enable PORTB pull-ups

TRISB = %11111000
TRISC = %10000000
led1 var PortC.0
cntr var byte
cntr = 0
TRISD = %00000000


Serout2 PORTD.5, 84, [$1B,$63,$30]
Serout2 PORTD.5, 84, [$1B,$45, "Start GSM SIMU"] ' Serial LCD
main:

PAUSE 1000
HSEROUT ["AT",13,10] 'Send AT to modem followed by a CR
pause 200
cntr=cntr+1
Serout2 PORTD.5, 84, [$1B,$45,"Start GSM SIMU"]
Serout2 PORTD.5, 84, [$D,"AT -Done",#cntr]
cntr=cntr+1

pause 1000
HSEROUT["AT+CMGF=1",13] 'Here the GSM module is being entered in TEXT MODE.
PAUSE 1000
HSEROUT ["AT+CSQ",13,10]
pause 200
Serout2 PORTD.5, 84, [$1B,$45,"Start GSM SIMU"]
Serout2 PORTD.5, 84, [$D, "SIGNAL CHK",#cntr]


PAUSE 1000
HSEROUT ["AT+CGMI",13,10] 'Ask model name
pause 200
cntr=cntr+1
Serout2 PORTD.5, 84, [$1B,$45,"Start GSM SIMU"]
Serout2 PORTD.5, 84, [$D, "MANUFACT CHK",#cntr]

Pause 1000
Serout2 PORTD.5, 84, [$1B,$45,"Start GSM SIMU"]
Serout2 PORTD.5, 84, [$D,"GSM TEST DONE!",#cntr]

End ' End of program



Can anyone pin point what I'm doing wrong in my code..and why HSERIN is not detecting data coming out from GSM?
I Appreciate any help.

Thanks in advance,
tacbanon

pedja089
- 15th July 2012, 09:58
Maybe problem is in supply voltage. Modem works on 2.8V(it have internal regulator), so pic should work on 3.3V, and you must have serial resistor on pic TX. So modem can't draw any current from pic TX pin.

tacbanon
- 15th July 2012, 10:19
Maybe problem is in supply voltage. Modem works on 2.8V(it have internal regulator), so pic should work on 3.3V, and you must have serial resistor on pic TX. So modem can't draw any current from pic TX pin.
Probably that is the case I'm having trouble with...serial resistor? Like a voltage divider?
Here is the general Specification of the GSM
Power Input:
5V-7.5VDC @ 1.5A

I/O Interface:
UART 3.3V Logic 5V Tolerant

Regards,
tacbanon

mackrackit
- 15th July 2012, 12:44
I still think you may need to use a max232 between the PIC and the device as you have mentioned the device works when connected directly to a PC.

ScaleRobotics
- 15th July 2012, 15:04
I still think you may need to use a max232 between the PIC and the device as you have mentioned the device works when connected directly to a PC.

if that is the case,

You can invert the comms for the pic18f4550. This will make it possible to talk to a modem without a rs232 chip: http://www.picbasic.co.uk/forum/showthread.php?t=10361

tacbanon
- 15th July 2012, 15:48
if that is the case,

You can invert the comms for the pic18f4550. This will make it possible to talk to a modem without a rs232 chip: http://www.picbasic.co.uk/forum/showthread.php?t=10361

I found it on page 240(datasheet) BAUDCON: BAUD Rate Control Register
Bit 4
1 = TX data is inverted
Bit 5
1 = RX data is inverted
Please correct me if I'm doing it wrong...
Baudcon.4 = 1
Baudcon.5 = 1

regards,
tacbanon

ScaleRobotics
- 15th July 2012, 15:55
That is correct. And make sure your voltages match, so no one gets hurt. :)

tacbanon
- 16th July 2012, 13:26
And make sure your voltages match, so no one gets hurt. :)
Sorry to ask this...but to make sure. GSM module I/O Interface UART 3.3V Logic 5V Tolerant, connecting to my LABX2 I think is safe even with the modification of BAUDCON...am right? :o

thanks for the help,
tacbanon

ScaleRobotics
- 16th July 2012, 18:49
Are you using some kind of shield, or the SIM900D development board? Can you point me to a schematic for the one you have? If shield, did you connect some kind of rs-232 to connect it to your computer?

tacbanon
- 16th July 2012, 23:07
Hi ScaleRobotics,
Yes I'm using a shield..sorry I can not seem to find the schematic. I used USB -to TTL module to communicate with the PC.
6595

/tacbanon

pedja089
- 16th July 2012, 23:24
Usb-TTL serial module use true 3.3V uart.
You port setup was ok, because you menage to get signal from modem, to pic, and send it to pc from pic...
Also TX from pic is ok, because you get result(post 17) on PC when you connect USB module to modem tx...
So check your ground, and check pic input type, maybe 2.8V isn't enough to ensure logic 1.

tacbanon
- 18th July 2012, 14:07
@pedja089
I checked the grounding..but still no changes.
Sorry for being a noob, but I tried to get the voltage from GSM Tx(4.2v) Rx(4.9v). I also tried to use max232..and still no positive results...I'm totally lost :(

/tacbanon

pedja089
- 18th July 2012, 15:36
I'm have board with sim900 connected to pic. Modem have 4V supply, pic have 3.3V.
SIM900 use TTL 2.8V true uart, not inverted. I put just 2 resistor in series with comm lines.
If you connect modem to rs232 side of max232, probably you frayed modem port.
1. Connect modem and usb board, and check that.
2. I tell you to try to connect your usb board to PIC instead of modem board. So you can check that communication is ok on PIC side...
You didn't try that...
So try to send response from PC to PIC. Only in HSERIN put longer timeout, eg 5s..
3.You said in post 10 you menage to get signal level. So your hardware setup was ok.

tacbanon
- 20th July 2012, 23:03
@pedja089
Hi sorry took me so long to reply...in post #10 I was able to get the signal level only once(upon power on)...I have to reset my LabX2 to get the reading again. I will try to get another GSM module probably by next week to see if the result is the same...and post here the output. Thanks all for the help and more power to PBP forum!

Regards,
tacbanon

pedja089
- 21st July 2012, 10:06
If you get once reply from modem, your hardware was ok.
Is anything was wrong you won't get reply if you restart or not...

ScaleRobotics
- 21st July 2012, 15:08
Hi tacbanon,

I loaded your code from post 19 into a circuit here, and tested hserout with your settings. I couldn't seem to get anything out, unless I removed your brown out reset in the configs.

If you change this line, does it help anything?

; __CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L & _BORV_2_2L & _VREGEN_ON_2L
__CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L & _VREGEN_ON_2L

As a side note, for 115200 baud on earlier code, I had to use:
'DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
'DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
'DEFINE HSER_CLROERR 1 ' Clear overflow automatically
'DEFINE HSER_SPBRG 25 ' 115200 Baud @ 48MHz, 0.16%

pedja089
- 21st July 2012, 15:42
Modem can draw up to 2A. So if you supply pic and modem from same power supply maybe voltage drops and lock your pic.

tacbanon
- 23rd July 2012, 16:14
Hi tacbanon,

I loaded your code from post 19 into a circuit here, and tested hserout with your settings. I couldn't seem to get anything out, unless I removed your brown out reset in the configs.

If you change this line, does it help anything?

; __CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L & _BORV_2_2L & _VREGEN_ON_2L
__CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L & _VREGEN_ON_2L

As a side note, for 115200 baud on earlier code, I had to use:
'DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
'DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
'DEFINE HSER_CLROERR 1 ' Clear overflow automatically
'DEFINE HSER_SPBRG 25 ' 115200 Baud @ 48MHz, 0.16%

Hello ScaleRobotics, That did it...yipee! :D
Thanks to you and thanks to everyone in the forum..

Regards,
tacbanon

ghulamqadir90
- 20th May 2015, 07:59
any one plz send C source code of above

Archangel
- 20th May 2015, 22:13
any one plz send C source code of above
This is NOT a "C" forum, it is as it's name implies a PIC BASIC Forum.

Soshin
- 20th July 2016, 10:28
PLZ send the source code of PIC BASIC<b style="color: rgb(62, 62, 62); font-family: Arial; font-size: x-small; line-height: 12.3px; background-color: rgb(233, 233, 233);"><form class="block vbform" action="http://www.picbasic.co.uk/forum/newreply.php?do=postreply&t=16806" method="post" name="vbform" style="margin: 0px auto 2em; padding: 0px; clear: both; width: auto; max-width: 100%;">


PIC BASIC


</form>
</b><b style="color: rgb(62, 62, 62); font-family: Arial; font-size: x-small; line-height: 12.3px; background-color: rgb(233, 233, 233);"><form class="block vbform" action="http://www.picbasic.co.uk/forum/newreply.php?do=postreply&t=16806" method="post" name="vbform" style="margin: 0px auto 2em; padding: 0px; clear: both; width: auto; max-width: 100%;">


PIC BASIC


</form>
</b>BASIC</pre>