Howto connect a PIC Microcontroller to a Telit GM862
How to connect a TELIT GM862 module to a PICMICRO.
In this project we connect the PIC microcontroller to the TELIT module by means of their UART peripherals. Due to different power supplies, we need to adapt PIC logic levels (where a logic "1" is almost 5V) to logic levels of the GSM module (2.8V at logic "1"). With a NPN-PNP transistor couple we accomplish this result.
There are alternative ways for logic level conversion, one of these could be a BCR22PN. Another way to convert from 2.8V -> 5V could be using a 74HC125. A series diode with its cathode tied to 5V and its anode tied to a pull up resistor to 2.8V are a simple logic level converter from 5V -> 2.8V.
One of the most used solution as Level Shifter is a CMOS buffer like 4049 (inverting) and the 4050 (not inverting).
An adjustable regulator LM350 supplies power to the GSM module. This module requires a 3.8V regulated DC supply, whereas the regulator filtering output capacitors are dimensioned to withstand current peaks caused when RF field is missing.
As alternative power supply a switching DC/DC could be used. Even an economic power supply [original output 5V, with two series diodes the final output goes to 3.6V) ] is a valid alternative but in this case the filter capacitor should be at least 2200uF.

Schematic pic2gm862.pdf
In the following paragraphs, we will walk through the project firmware. The original release uses a PIC16 microcontroller whose firmware is written in assembly language (for those afraid of high level languages). For those afraid of low level programming we provide a C source code, implemented on a PIC18 microcontroller.
Before facing crude code let's summarize the major features we program to set up the GSM module :
- Soon after reset, GM862 is set in autobaud mode, so first an AT command is sent, then the autobaud is disabled, setting the desired baud rate.
- Echo can be disabled as well, lowering the amount of inbound data, thus reducing receive buffer dimension.
- Activating call identification, inbound calling number is available for visualization.
- A nice feature that helps your debugging is enabling extensive report of errors, whose codes are well documented in the GM862 manual.
- Setting the SMS format to text relieves programmer to implement decoding routines.
- Disable new incoming messages indication .
- Select the phone SIM Card as memory storage.
Initialization of TELIT GM862 module using C language (Microchip MPLAB C18)
Since PIC and GM862 are connected by means of UARTS, we can take advantage of a ready at hand C function putrsUSART(); (take a look at the C18 reference manual)
//-----------------------------------------------------------------------------------------------------------
// Telit GM862 initialize C18
//------------------------------------------------------------------------------------------------------------
setup_gm862:
// turn on the telit module and verify, else reset autobaud
gm_POWER_ON();
// reset ram pointer
lungh = 0;
// AT command test
// response: AT
putrsUSART ((const far rom char *)"AT\r");
Delay10KTCYx (50);
// set_baud
lungh = 0; //
// set_baude_rate 300,1200,2400,4800,9600,19200......
// response: OK
putrsUSART ((const far rom char *)"AT+IPR=9600\r");
Delay10KTCYx (50);
// disable_echo
lungh = 0;
// Disable echo command
// response: OK
putrsUSART ((const far rom char *)"ATE=0\r");
Delay10KTCYx (50);
// caller_id
lungh = 0;
// Set CALLER ID; 1=on
// response: OK
putrsUSART ((const far rom char *)"AT+CLIP=1\r");
Delay10KTCYx (10);
// error_code
lungh = 0;
// Enable extended error code ; 1 =numeric
// response: OK
putrsUSART ((const far rom char *)"AT+CMEE=1\r");
Delay10KTCYx (10);
// sms_format
lungh = 0;
// SMS format type; 1=text
// response: OK
putrsUSART ((const far rom char *)"AT+CMGF=1\r");
Delay10KTCYx (10);
// unsolecit_ind
lungh = 0;
// DISABLE New message unsolecited indication +CMTI
// response: OK
putrsUSART ((const far rom char *)"AT+CNMI=0,0,0,0,0\r");
Delay10KTCYx (10);
// storage_set
lungh = 0;
// AT+CPBS="SM" set phonebook normal SIM
putrsUSART ((const far rom char *)"AT+CPBS=\"SM\"\r");
Delay10KTCYx (50);
//--------------------------------------------------------------------------------------------------------------
Initialization of TELIT GM862 module using Assembly language (Microchip MPLAB MPASM )
PIC uses the UART to send commands and receive data from GM862. Its software uses a transmission routine labeled TransWt. An ISR triggered by incoming data handles the reception. This data is stored in a buffer RAM area starting at location 0xA0 that's why FSR is set to 0xA0. This area is initially cleared (filled with zeroes).
;================================================================ ; Telit GM862 initialize ASM ;================================================================ setup call clear_ramA0 ; clears the ram from A0h to EFh and 120h to 14Fh preset FSR=0xA0 call at ; at_command call clear_ramA0 call _ipr ; fix port rate @ 9600 call clear_ramA0 call ate ; Disable command echo call clear_ramA0 call _clip ; Enable calling line identification call check_ok ; verify OK SKPZ ; Z=1 OK goto setup1 ; error --> no_ok turn off and turn on the module! call clear_ramA0 call _cmee ; Enable extended error code =1 numeric call clear_ramA0 call _cpin ; SIM presence checking (PIN free) READY call clear_ramA0 call _creg ; Network checking x,1 (home) or x,5 (roaming) call clear_ramA0 call _cmgf ; SMS format type 1=text call clear_ramA0 call _csca ; Check SMS Center Service number call clear_ramA0 call _cnmi ; DISABLE New message unsolicited indication +CMTI: call clear_ramA0 call _fclass ; AT+FCLASS=8 Activate Voice mode call clear_ramA0 ; Set TEXT mode parameters call _csmp ; 17,167,0,0 call check_ok ; verify OK SKPZ ; Z=1 OK goto setup1 ; error --> no_ok turn off and turn on the module! setup2 call clear_ramA0 call _cpbs ; AT+CPBS="SM" set phonebook normal SIM call check_ok ; verify OK SKPZ ; Z=1 OK goto setup2 ; error --> no_ok loop ;###############################################
Following is an example of a routine sending an AT command. We leave a 500mS delay allowing the module to perform the requested action. When this delay is over, a new command can be sent. This delay can be reduced for a faster transfer rate, but, even better, we could wait for the module answer and depending on it, choose the following step as in the following diagram:
Is Answer OK ? Yes > Continue
No > Error Analysis > Errors Management
;------------------------------------------------------------------------ ; EXAMPLE OF COMMAND ROUTINE FOR TELIT GM862 ; ; AT COMMAND ; AT+CPBS="SM" ;------------------------------------------------------------------------ _cpbs movlw 'A' call TransWt movlw 'T' call TransWt movlw '+' call TransWt movlw 'C' call TransWt movlw 'P' call TransWt movlw 'B' call TransWt movlw 'S' call TransWt movlw '=' call TransWt movlw '"' call TransWt movlw 'S' call TransWt movlw 'M' call TransWt movlw '"' call TransWt movlw .13 ; call TransWt call t500ms return ;--------------------------------------------------------------------------------
Resources
The following post is worth reading:
Reuse Your old personal GSM phone for SMS control and monitoring [for hobby use].
This is a complete project of a remote telecontrol using old mobiles. Here you can find many links to similar projects using several brands and models of mobile phones.
Panoramic on GSM modules manufacturers
TELIT GSM/GPRS QuadBand modules with integrated GPS and in BGA format
SIEMENS Modules GSM/GPRS Triband also with integrated GPS, modules EDGE quadband. Interfaces SPI and I2C
WAVECOM Modules GSM and GPS tracking. Interesting the suite Open AT
SONY-ERICSSON Modules GSM/GPRS EDGE and for the GPS tracking
Useful links
www.telit.co.it/product.asp?productId=96 [GM862 documentation TELIT site]
www.roundsolutions.com/gsm-modem/index.htm [GM862 documentation site RoundSolutions]
www.ee01.it/ [Read the article on EE01 module telit + PIC]
www.comprel.it/ [TELIT DISTRIBUTOR]
www.arrowlasi.com/ [TELIT DISTRIBUTOR]
www.telit.co.it/modules.asp Official site of Telit GSM module
www.roundsolutions.com/forum The reference forum Telit modules developers
www.ipersms.com/en SMS Receiver. Can be used also as DemoBoard in order to connect the GM862 to the PC
www.ipergate.com GSM Gate opener. Example of application with PIC and GM862
www.gsmworld.it All about GSM
www.etsi.org The official detailed lists of the protocol
pda.etsi.org/pda/queryform.asp In order not to get lost in the ETSI site
Some background that's good sharing...
Sending calls with TELIT GM862
Using the phone book-SIM Card of TELIT GM862
Hanging SMS problem
Sending SMS with the TELIT GM862 module
- Emanuele's blog
- 10451 reads





Thank you
Thank you for this useful article. I'll be using one of these modules for a future project at work for receiving data from water quality probes that communicate via RS-232.
Problems Using the GM862
Hi,
I write AT to the GSM modules but it doesn't response anithyg back, i test everthing, voltege levels, i'm using a MAX560 to interface it to the PC serial port, i have only to send AT (at 9600 8 n 1) and and wait for the OK response? the OK response never arrives.. any suggest? you can see my schematic at http://elcesar.com.ve/downloads
Thanks for all your help.
Post new comment