GSM interfacing with LPC2148
Global system for mobile communication:
Features of GSM modem:
- Single supply voltage 3.2v-4.5v.
- Typical power consumption in SLEEP Mode: 2.5mA.
- SIM300 tri-band.
- MT,MO,CB, text and PDU mode, SMS storage: SIM card.
- Supported SIM Card :1.8V,3V.
Block diagram:
Block diagram |
GSM modem |
GSM mobile vs GSM module:
- A GSM mobile is a complete system in itself with embedded processors that are dedicated to provide an interface between the user and the mobile network.
- The AT commands are served between the processors of the mobile termination and the terminal equipment.
- The mobile handset can also be equipped with a USB interface to connect with a computer, but it may or may not support AT commands from the computer or an external processor/controller.
- The GSM/GPRS module, on the other hand, always needs a computer or external processor/controller to receive AT commands from.
- GSM/GPRS module itself does not provide any interface between the user and the network, but the computer to which module is connected is the interface between user and network.
- An advantage that GSM/GPRS modules offer is that they support concatenated SMS which may not be supported in some GSM mobile handsets
- Applications of GSM/GPRS module The GSM/GPRS module demonstrates the use of AT commands. They can feature all the functionalities of a mobile phone through computer like making and receiving calls, SMS, MMS etc. These are mainly employed for computer based SMS and MMS services.
AT Commands:
- AT commands are used to control MODEMs.AT is the abbreviation for Attention.
- These commands come from Hayes commands that were used by the Hayes smart modems.
- The Hayes commands started with AT to indicate the attention from the MODEM.
- The dial up and wireless MODEMs need AT commands to interact with a computer.
- AT commands with a GSM/GPRS MODEM.
AT Commands |
Pin assignment with LPC2148:
Uart pins of LPC2148 |
Algorithm :
- Start
- Initialise UART1 serial interface.
- Transmit different AT commands through UART.
- If transmission buffer is Empty,Transmit AT commands.
- Provide delay while transmitting each command.
- To transmit a single character use PUTCH function & to transmit a string use PUTS function.
- End
Code: GSM interfacing with LPC2148
/**********************************************************
Expt. ***: GSM interfacing with to LPC2148
Platform: LPC2148 Development Board.
College: PICT
**********************************************************/
#include<lpc21xx.h> //Includes LPC2148 register
unsigned char GsmSendMsg(unsigned char *msgStr);
void DelayMs(unsigned int count);
void uart1Init(void);
void uart1Putch(unsigned char ch);
void Uart1PutS(unsigned char *Str);
int main(void)
{
Uart1Init();
Uart1PutS("AT\r\n");
DelayMs(500);
Uart1PutS("ATE0\r\n"); //Turn echo off
DelayMs(500);
Uart1PutS("ATD9503XXXXXX;\r\n"); //replace xxxxxxxxxx with number to call
DelayMs(20000);
Uart1PutS("ATH0\r\n"); //disconnect call
DelayMs(3000);
GsmSendMsg("Welcome to PICT");
while(1);
}
unsigned char GsmSendMsg(unsigned char *msgStr)
{
Uart1PutS("AT+CMGF=1\r\n");//Send SMS: Select Text mode
DelayMs(100);
Uart1PutS("AT+CMGS=\"9960XXXXXX\"\r\n"); //Send SMS to mobile number
DelayMs(100);
Uart1PutS(msgStr);
DelayMs(100);
Uart1PutCh(0x1A); //CNTL + Z
DelayMs(3000);
return (1);
}
void DelayMs(unsigned int count)
{
volatile unsigned int j,k;
for (j=0;j<count;j++)
for (k=0;k<6000;k++);
}
void uart1Init(void)
{
PINSEL0=0x00050000;// port 0 tx P0.8 and rx P0.9
U1LCR=0x83; //8bit data, no parity, 1 stop bit
U1DLL=97;// 9600 baud rate @15Mhz Pclk
U1LCR=0x03;// DLAB=0
}
void uart1Putch(unsigned char ch)
{
U1THR=ch; // Transmitter holding register
while(!(U1LSR & 0x20));// wait still THR=0
}
void Uart1PutS(unsigned char *Str)
{
int i=0;
while(Str[i]!='\0')
{
uart1Putch(Str[i]);
i++;
}
}
/**********************************************************
Expt. ***: GSM interfacing with to LPC2148 Platform: LPC2148 Development Board. College: PICT **********************************************************/
#include<lpc21xx.h> //Includes LPC2148 register
unsigned char GsmSendMsg(unsigned char *msgStr);
void DelayMs(unsigned int count);
void uart1Init(void);
void uart1Putch(unsigned char ch);
void Uart1PutS(unsigned char *Str);
int main(void)
{
Uart1Init();
Uart1PutS("AT\r\n");
DelayMs(500);
Uart1PutS("ATE0\r\n"); //Turn echo off
DelayMs(500);
Uart1PutS("ATD9503XXXXXX;\r\n"); //replace xxxxxxxxxx with number to call
DelayMs(20000);
Uart1PutS("ATH0\r\n"); //disconnect call
DelayMs(3000);
GsmSendMsg("Welcome to PICT");
while(1);
}
unsigned char GsmSendMsg(unsigned char *msgStr)
{
Uart1PutS("AT+CMGF=1\r\n");//Send SMS: Select Text mode
DelayMs(100);
Uart1PutS("AT+CMGS=\"9960XXXXXX\"\r\n"); //Send SMS to mobile number
DelayMs(100);
Uart1PutS(msgStr);
DelayMs(100);
Uart1PutCh(0x1A); //CNTL + Z
DelayMs(3000);
return (1);
}
void DelayMs(unsigned int count)
{
volatile unsigned int j,k;
for (j=0;j<count;j++)
for (k=0;k<6000;k++);
}
void uart1Init(void)
{
PINSEL0=0x00050000;// port 0 tx P0.8 and rx P0.9
U1LCR=0x83; //8bit data, no parity, 1 stop bit
U1DLL=97;// 9600 baud rate @15Mhz Pclk
U1LCR=0x03;// DLAB=0
}
void uart1Putch(unsigned char ch)
{
U1THR=ch; // Transmitter holding register
while(!(U1LSR & 0x20));// wait still THR=0
}
void Uart1PutS(unsigned char *Str)
{
int i=0;
while(Str[i]!='\0')
{
uart1Putch(Str[i]);
i++;
}
}
No comments:
Post a Comment