Professional Documents
Culture Documents
MAX ARM 7
232 LPC2148
Interfacing GSM using UART
Interfacing Signals: RxD, TxD, Gnd
Maximum Characters/SMS 140
AT commands are used to send and receive
SMS.
AT Commands
AT commands are used to control MODEMs.
AT is the abbreviation for Attention.
Case Sensitivity - The AT commands are
generally used in uppercase letters.
AT Commands
AT commands are used to control MODEMs.
AT is the abbreviation for Attention.
Case Sensitivity - The AT commands are
generally used in uppercase letters.
AT Commands
Single Command - The extended AT
commands have a + in the command name.
For example: AT+CGMI<Carriage return>
AT Commands
Command Line - Multiple AT commands can be sent
to MODEM in a single command line.
AT+CGMI; +CBS<Carriage return>.
AT Commands
For Sending SMS:
1. First select the text mode for SMS- AT+CMGF = 1 .
2. Send mobile number to the GSM Modem
AT+CMGS =+923005281046
3. Send the text message string ("hello!")
4. Send ASCII code for CTRL+Z i.e., 0x1A to GSM
Modem to transmit the message to mobile phone.
5. Every AT command is followed by i.e. carriage
return and line feed
GPS Interfacing
GPS receivers use a group of satellites and
ground stations to compute position and time
almost anywhere on earth.
GPS Receiver Module
GPS Receiver Module
Once a GPS module is powered, NMEA
(National Marine Electronics Association) data
is sent out of a serial transmit pin (TX) at a
specific baud (4800 bps) rate.
GPS
The data given by the GPS receiver includes
many information like position (latitude and
longitude), altitude, speed, time etc.
GPS
The GLLdataset (geographic position
latitude/longitude) contains information on
latitude and longitude, time and health.
Example of a GLL dataset:
$GPGLL,4717.115,N,00833.912,E,130305.0,A*
32<CR><LF>
On chip ADC
Features
Power-down mode.
int data[200],length=0,i=0;
char var='A';
char ivar='a';
int main(void)
{
i2c_init();
i2c_eeprom_write(0,0,0,26);
i2c_eeprom_read(0,0,0,26);
return 0;
}
void i2c_init()
{
*PINSEL0 = *PINSEL0 & 0XFFFFFF0F; // SELECT THE PIN for I2C
*PINSEL0 = *PINSEL0 | 0X00000050;
*I2CONCLR = I2ENC | STAC | STOC | SIC | AAC;
*I2SCLH = 150; //set the bit frequency to 50 khz
*I2SCLL = 150;
}
void i2c_eeprom_write(u8 dev_addr,u8 page_no,u8 page_offset,u32 no_bytes)
{
*I2CONSET = I2EN;
delay(1000);
*I2CONSET = STA;
wait_for_ack(0x08); // I2C state change
*I2DAT = 0XA0; // transmit slave address with write bit
*I2CONCLR = SIC;
*I2CONCLR = STAC; // clear the START bit to avoid retransmition of START
wait_for_ack(0x18);
*I2DAT = page_no; // transmit page address
*I2CONCLR = SIC;
wait_for_ack(0x28);
*I2DAT = page_offset; // transmit offset within the page
*I2CONCLR = SIC;
while(no_bytes > 0)
{
wait_for_ack(0x28);
*I2DAT = var++;
no_bytes--;
*I2CONCLR = SIC;
}
wait_for_ack(0x28);
*I2CONCLR = SIC;
*I2CONSET = STO ;
}
*I2CONCLR = I2ENC | STAC | STOC | SIC | AAC;
}
void i2c_eeprom_read(u8 dev_addr,u8 page_no,u8 page_offset,u32 no_bytes)
{ length = no_bytes;
*I2CONSET = I2EN ;
delay(1000);
*I2CONSET = STA;
wait_for_ack(0x08);
*I2CONCLR = STAC;// clear the START bit to avoid retransmit of START
*I2DAT = 0XA0;
*I2CONCLR = SIC;
wait_for_ack(0x18);
*I2DAT = page_no;
*I2CONCLR = SIC;
wait_for_ack(0x28);
*I2DAT = page_offset;
*I2CONCLR = SIC;
wait_for_ack(0x28);
I2CONCLR = SIC;
I2CONSET = STA ;
wait_for_ack(0x10);
I2CONCLR = STAC; //put the address and the read bit
I2CONSET = AA;
I2DAT = 0XA1;
I2CONCLR = SIC;
wait_for_ack(0x40);
I2CONCLR = SIC;
while(no_bytes>0)
{ wait_for_ack(0x50);
data[no_bytes] = *I2DAT;
no_bytes--;
I2CONCLR = SIC;
}
wait_for_ack(0x50);
I2CONCLR = AAC;
I2CONCLR = SIC;
wait_for_ack(0x58);
I2CONSET =STO ;
I2CONCLR = I2ENC | STAC | STOC | SIC | AAC;
read_data();
}
void read_data()
{
q_printf("\n\n Final Data read from the Slave::\n\n ");
int i=0;
for(i=length;i>0;i--)
{
q_printf(" %c", data[i]);
}
}
void wait_for_ack(u32 status)
{
while(1)
{
if(*I2CONSET & SI)
{
if(*I2STAT == status)
{
break;
}
else
{
q_printf("\n ERROR STATUS RECEIVED = ");
q_printf("%x", *I2STAT);
*I2CONSET = STO;
*I2CONCLR = 0xFF;
asm("b loop_forever");
}
}
}
}
SD Card Interfacing using SPI
Secured Digital Memory Card
SPI frame format and data size. The SPI format and data size can
be configured through setting the proper clock polarity bit (CPOL)
and clock phase bit (CPHA) and data size field (DSS) in the SSP
control registers (SSPCR0). The data size is set to 8 bits/frame, and
both CPOL and CPHA bits are set to zero.