You are on page 1of 8

Dept. of Electronics and Telecom.

ADVANCED PROCESSORS

EXPERIMENT NO: 2

Aim: GSM (Global System for Mobile Communication) interfacing with LPC2148.

Objectives: After performing this experiment, the learner will be able to interface GSM
module with LPC 2148 using Embedded C program and observe the output on display.

Apparatus: LPC2148 Evaluation Board, USB to Serial communication cable, Power supply
adaptor. PC with Keil uVision4 and Flash Magic software, GSM Module.

Theory:
GSM (Global System for Mobile Communication) :
GSM is a digital mobile telephony system. GSM digitizes and compresses data, then
sends it down a channel with two other streams of user data, each in its own time slot. It
operates at either the 900 MHz or 1800 MHz frequency band.
Fig. shows how to interface the GSM with microcontroller. The GSM module is communicate
the microcontroller with mobile phones through UART. To communicate over UART or USART, we
just need three basic signals which are namely, RXD (receive), TXD (transmit), GND (common
ground). GSM modem interfacing with microcontroller for SMS control of industrial equipment’s.
The sending SMS through GSM modem when interfaced with microcontroller or PC is much simpler
as compared with sending SMS through UART. Text message may be sent through the modem by
interfacing only three signals of the serial interface of modem with microcontroller i.e., TxD, RxD
and GND. In this scheme RTS and CTS signals of serial port interface of GSM Modem are connected
with each other.
The transmit signal of serial port of microcontroller is connected with transmit signal (TxD) of
the serial interface of GSM Modem while receive signal of microcontroller serial port is connected
with receive signal (RxD) of serial interface of GSM Modem. The SMS message in text mode can
contain only 140 characters at the most. It depends upon the amount of information collected from
GPS Engine that you need at the base station for tracking vehicle or person.

TE ELECTRONICS Page No.


Dept. of Electronics and Telecom. ADVANCED PROCESSORS

Interfacing GSM with LPC2148


We now want to display a text in mobile from LPC2148 Primer Board by using GSM module
through UART (UART: Universal Asynchronous Receiver Transmitter .)
. In LPC2148 Primer Board contains two serial interfaces that are UART0 & UART1. Here
we are using UART0. The GSM modem is being interfaced with the microcontroller
LPC2148 Primer Board for SMS communication. The SMS can be sending and receiving for

the data sharing and situation information and control .


Pin Assignment with LPC2148

TE ELECTRONICS Page No.


Dept. of Electronics and Telecom. ADVANCED PROCESSORS

Inferfacing Diagram:

Procedure:
1. Provide +5v dc power supply to ARM LPC2148 board .
2. connect ARM LPC2148 board to computer using USB cable .
3. Open Keil uVision4
4. Select new project
5. Then go on local drives (desktop) & create folder and give file name related to our
project and save this file.

TE ELECTRONICS Page No.


Dept. of Electronics and Telecom. ADVANCED PROCESSORS

6. Then Select device(nxp-LPC2148)


7. After this one window will appears “start-up file”, click on yes.
8. Go to file select new file and write code in this new file and save this file as “Main.c”
file then right click on target and select “options for target ” in this click on linker and
select “use memory layout”. click on output and select “create hex file”.
9. Also create another new file for UART and write code in this new file and save with
“UART.c” extension. Double click on source group 1 and add these “.c ” files.
10. Click on “translate current file ” , click on “build target” , click on” rebuild all target
files”
11. Open flash magic
12. Select device LPC2148. Select com port which has been utilised by our ARM LPC
2148 board (right click computer then click on properties, after this goto hardware
and click on device manager . In device manager observed which port has been
utilised by “prolific drivers” )
13. Set baud rate -9600
14. Set interface-none
15. Set oscillator frequency 12 Mhz
16. Click on “erase all flash codes”
17. Browse and select hex file which has been created in our project folder
18. Go to isp and click on read device signature if device is not ready then at a same
press reset and interrupt key on ARM LPC 2148 board and first release reset and then
interrupt .
19. Then click on start load programme in to LPC2148
20. Open Hyper Terminal (on Flash Magic --- Tools--- Terminal --- Terminal Settings ---
Hyper Terminal )

21. To observe output press reset.

Algorithm :-
Main Routine:-
1. 1. Start
2. Declare TxD0 and RxD0 pin for UART0

TE ELECTRONICS Page No.


Dept. of Electronics and Telecom. ADVANCED PROCESSORS

3. Initialize UART0
4. Declare different functions used in Main program
5. Send mobile Number through AT command
6. Send message through AT command
7. Stop

Flow Chart for Main Routine:-

Start

Declare TxD0 and RxD0 pin


for UART0

Initialize UART0

Declare different functions


used in Main program

Send mobile Number through


AT command

Send message through AT


command

Stop
TE ELECTRONICS Page No.
Dept. of Electronics and Telecom. ADVANCED PROCESSORS

Code:

#include "lpc214x.h"
#include "UART.h"
#include "stdio.h"
#include "string.h"

void delay(unsigned int time)


{
unsigned int i,j;
for(i=0;i<time;i++)
for(j=0;j<5000;j++);
}

void GSM_cmd(unsigned char *cmd)


{
printf("\r\ncommand: %s",cmd);
printf("response: ");
UART1_PutS(cmd);
delay(100);
}

int main()
{
unsigned char *msg = "ADVANCED PROCESSOR\r";

Uart0Init(9600);
Uart1Init(9600);
printf("GSM program\r\n");

GSM_cmd("ATE0\r\n");
//Turn OFF echo
delay(3000);

GSM_cmd("ATD7757901312;\r\n"); //Call
(CHANGE THIS NUMBER)
delay(20000);
GSM_cmd("ATH0\r");
//disconnect call
delay(3000);

TE ELECTRONICS Page No.


Dept. of Electronics and Telecom. ADVANCED PROCESSORS

GSM_cmd("AT+CMGF=1\r\n");
//Send SMS: Select Text mode
delay(1000);
GSM_cmd("AT+CSCS=\"GSM\"\r\n"); //GSM
Character Set
delay(1000);
GSM_cmd("AT+CMGS=\"7757901312\"\r\n"); //Number
(CHANGE THIS NUMBER)
delay(1000);
UART1_PutS(msg); //Send
string
delay(1000);
UART1_PutChar(0x1A);
//SUBSTITUTE character <CTRL+Z>

while(1);
return 0;
}

/**************************************************************************
End Of File
**************************************************************************/

Output:-

Conclusion:

TE ELECTRONICS Page No.


Dept. of Electronics and Telecom. ADVANCED PROCESSORS

Thus we have studied GSM interfacing with LPC 2148 and also ATD commands.

TE ELECTRONICS Page No.

You might also like