Interfacing GSM With LPC2148 For Sending and Receiving Message and Voice Call
Interfacing GSM With LPC2148 For Sending and Receiving Message and Voice Call
LAB 3: Interfacing GSM with LPC2148 for sending and receiving message and
voice call
Part List:
Educational practice board for ARM7 LPC2148
All in One General Purpose Board (ASK25)
+9V Power supply
USB A to B type cable
20 pin flat cable
GSM Modem
PC
Eclipse IDE
Flash Magic Utility
Hardware Connection:
Connect USB cable between PL3 connector of EPBARM7 and PC.
Connect 20 Pin flat cable between J1 connector of EPBARM7 board and PL3 connector of
ASK25.
Insert SIM card in GSM Modem and connect Power supply to GSM modem.
Connect GSM modem to P8 connector of EPBARM7 board.
Included Files:
____________________________________________________________________________
Edutech Learning Solutions Pvt. Ltd. [email protected]
Laboratory workbook for Advanced Microprocessors (As per Pune University Syllabus)
Program Listing:
//message
#include"gsm.h"
#include"lcd_lowerlevel.h"
void main()
{
unsigned char dataBuf[8];
unsigned char *num="09439569077";
unsigned char *message="hi how are u";
unsigned char *c;
int j,i=0;
ConfigUart(Uart0,9600);
InitLcd(Inc,DispShiftOff);
GSM_TMODE(Uart0,dataBuf);
if(dataBuf[12]==0x4F)
{
ClearLcd();
DisplayString("Text Mode",1,1,Off);
DisplayString("Selected",2,1,Off);
DelayMs(1000);
}
else
{
ClearLcd();
DisplayString("Text Mode",1,1,Off);
DisplayString("Not Selected",2,1,Off);
while(1);
}
DisplayString("Mobile number=",1,1,Off);
DisplayString(num,2,1,Off);
GSM_SendSMS(Uart0,num,message);
DelayMs(1000);
ClearLcd();
c="MeSsAgE sEnT";
DisplayString(message,1,1,Off);
DelayMs(2000);
ClearLcd();
for(j=1;j<=12;j++)
{
DisplayCharacter(c[i++],2,j,Off);
DelayMs(100);
}
while(1);
____________________________________________________________________________
Edutech Learning Solutions Pvt. Ltd. [email protected]
Laboratory workbook for Advanced Microprocessors (As per Pune University Syllabus)
Result:
It will message a number you entered in program and display status on LCD.
____________________________________________________________________________
Edutech Learning Solutions Pvt. Ltd. [email protected]
Laboratory workbook for Advanced Microprocessors (As per Pune University Syllabus)
Part List:
Educational practice board for ARM7 LPC2148
All in One General Purpose Board (ASK25)
+9V Power supply
USB A to B type cable
20 pin flat cable
GSM Modem
PC
Eclipse IDE
Flash Magic Utility
Hardware Connection:
Connect USB cable between PL3 connector of EPBARM7 and PC. Connect 20 Pin flat
cable between J1 connector of EPBARM7 board and PL3 connector of ASK25.
Connect Power supply to GSM modem and insert SIM card in it.
Connect GSM modem to P8 connector of EPBARM7 board.
Included Files:
____________________________________________________________________________
Edutech Learning Solutions Pvt. Ltd. [email protected]
Laboratory workbook for Advanced Microprocessors (As per Pune University Syllabus)
Program Listing:
/** This Program is used to make a call using GSM Modem on a specified number.
*/
#include "lpc214x.h"
/* Macro Definitions */
#define SET(x) (1<<x)
#define CLR(X) (0<<X)
#define CRYSTAL_FREQUENCY_IN_HZ 11059200
#define PLL_MULTIPLIER 1
/* Main Program */
int main(void)
{
char status=0;
Lcd_Init();
Uart0_Init(9600); // UART0 initialized with
Baudrate=9600
Lcd_String("GSM Calling...");
status = GSM_Call ();
Lcd_Cmd(0xC0);
if(status)
Lcd_String("Call: Successful");
____________________________________________________________________________
Edutech Learning Solutions Pvt. Ltd. [email protected]
Laboratory workbook for Advanced Microprocessors (As per Pune University Syllabus)
else
Lcd_String("Call: Failed");
while(1);
}
/***************************************************************************
UART0 Functions
******************************************************************************/
/** This Program initialize the UART0 **/
void Uart0_Init(unsigned long BaudRate)
{
unsigned int CountVal;
VPBDIV = 0X01; // to choose pclk=cclk
PINSEL0 &= ~0x0F; // Clearing GPIO Values for Pin0.0 and P0.1 to config it for UART0
PINSEL0 |= 0x05; // Configure P0.0 and P0.1 for UART0 TxD and RxD
IO0DIR &= ~0x02; // Direction: P0.1 RX as input
IO0DIR |= 0x01; // Direction: P0.0 TX as Output
CountVal = FOSC /(16 * BaudRate); // Pg.150 LPC2148 User Manual (Rev. 4.0 2012
Edition)
U0LCR |= (0x01<<7); // Divisor latch enable for setting of Fractoinal
divisor value
/***************************************************************************
GSM Functions
******************************************************************************/
char GSM_Call(void)
{
Uart0_String("ATD09427304539;\r");
____________________________________________________________________________
Edutech Learning Solutions Pvt. Ltd. [email protected]
Laboratory workbook for Advanced Microprocessors (As per Pune University Syllabus)
if(GSM_Ack())
return(1);
else
return(0);
}
/***************************************************************************
LCD Functions
******************************************************************************/
/*** This function is used to Toggle Enable pin for LCD. ***/
void Toggle_En(void)
{
Delay(DELAY_250US); // Delay larger for 8bit mode
IO0SET = 0X00000080; // Enable pin = 1;
Delay(DELAY_250US); // Delay larger for 8bit mode
IO0CLR = 0X00000080; // Enable pin = 0;
}
Delay(DELAY_TINY);
Toggle_En(); // Toggle Enable pin to latch command
Delay(DELAY_250US); // Delay : To stabilize the command
}
Delay(DELAY_15MS);
____________________________________________________________________________
Edutech Learning Solutions Pvt. Ltd. [email protected]
Laboratory workbook for Advanced Microprocessors (As per Pune University Syllabus)
Result:
A call would be made via modem on the number mentioned in the program.
____________________________________________________________________________
Edutech Learning Solutions Pvt. Ltd. [email protected]