I have one Doubt how void uart(void)__irq this function call in this program..........????
#include "lpc21xx.h" // #include "lpc210x.h" #include "stdio.h" #define baudrate_uart1 0x0f //@115200;SYS_CLK/16*2*COUNT=0x0f #define sender_no "+919328178092" #define sms "Advance Technology rising company in future" #define CR 0x0D #define LF 0x0A /****************************Prototypes****************************/
void delay(void); void getch (char ch); char *gps_strchr(char *src, char ch); int gps_strncmp( char *s1, char *s2, unsigned char length); int gps_strcpy1(unsigned char *s1,char *s2); const char *uart1Puts(const char *string); int uart1Putch(int ch); void uart1_interrupt(void); void uart1_initialize(void); void check_response(char *sentence); void lcd (int length) ; void instwrt(void); void datawrt(void); void lcd_init(void); char at_get_running; char at_get_buff[160],*at_get_idx;
char response_ok=0; char lcd_buffer[20],temp123[200]; static char array1[160];
int main() {
VPBDIV=2; IODIR0=IODIR0|0x0f00fffc;
uart1_initialize(); uart1_interrupt(); lcd_init();
uart1Puts("AT" ) ; uart1Putch(CR); delay();
while(response_ok!=1) //check response for previous cmd { response_ok=0; //uart1Puts("AT+CMGF=1" ) ; // uart1Putch(CR); // delay();
//uart1Puts("AT+CMGS=" ) ; //uart1Putch('"'); //uart1Puts(sender_no) ; //uart1Putch('"'); //uart1Putch(CR); //uart1Puts(sms); // uart1Putch(26); // delay(); } while(1) {
} }
/***************************************************************************** * FUNCTION : UART1 interrupt * PURPOSE : for data capturig at baudrate 115.2kbps * INPUTS : receive interrupt * RETURNS : none *****************************************************************************/
void uart(void)__irq { char status,temp; if((U0LSR & 0x01)==0x01) { status=U0RBR; getch(status);
} VICVectAddr=0; temp=U0IIR;
} /***************************************************************************** * FUNCTION : get_ch * PURPOSE : gets the ch from GPRS and findout gprs responses and route table information * INPUTS : passing ch receive from uart1 receive interrupt * RETURNS : none *****************************************************************************/ void getch (char ch) {
static char ch_count1=0;
if( ch_count1<150) { array1[ch_count1]=ch; ch_count1++; } else ch_count1=0;
if((ch ==LF)&&(!at_get_running)) //start of response { at_get_running = 1; //sentence being recieved flag true at_get_idx = at_get_buff; }
if(at_get_running) { if((ch== LF)&&(at_get_idx == (at_get_buff+1))) //start of response received { at_get_idx = at_get_buff; } else if((ch == CR)&&(at_get_idx > (at_get_buff+1))) //end of response { at_get_running = 0; *at_get_idx = 0; check_response( at_get_buff); } else { if(ch!=LF) *at_get_idx++ = ch; //update buffer with response on uart } }
}
/***************************************************************************** * FUNCTION : int check_response(void) * PURPOSE : check AT response type from response strored in buffer and * return appropriate value according to type * INPUTS : sentence: address of buffer * RETURNS :1 on success 0 on error/busy
*****************************************************************************/ void check_response(char *sentence) {
if(gps_strncmp(sentence, "RING", 4) == 0) { response_ok=1; // lcd_buffer[]={}; gps_strcpy1(lcd_buffer,"CALL FOR U"); lcd(10); uart1Puts("ATA" ) ; uart1Putch(CR); delay();
} else if(gps_strncmp(sentence, "NO CARRIER", 10) == 0) { response_ok=0; gps_strcpy1(lcd_buffer,"MISS CALL"); lcd(9); }
else if(gps_strncmp(sentence, "+CMTI:", 6) == 0) //+CMTI: "SM",16 ==cmti is receive response, sm: sim memory, 16 location number { // maximum 30 sms stored gps_strcpy1(lcd_buffer,"NEW MSG RECEIVED"); lcd(16);
//lcd(16);
} else if(gps_strncmp(sentence, "RING", 4) == 0) response_ok=1;
else if(gps_strncmp(sentence, "OK", 2) == 0) response_ok=1; } /***************************************************************************** * FUNCTION : gps_strchr * PURPOSE : Searches for the character and returns the location * * INPUTS : char *src - source string * char ch - character to be searched
* RETURNS : address location of character in string
*****************************************************************************/
Thanks for Reply Sir , i am an student and i just start a project
1. I want to read a sms by Arm7 Tdmi-s lpc2106 micro controller 2. I have to use AT commands for reading this SMS Command for Read sms AT+CMGR= I I= index of sms in sim card........... i am able to see when a sms comes its display New message comes in Lcd BUT I WANT TO READ Content of this sms after reading want to do some other operations 3. i have doubt that how is this interrupt work in this micro controller Plz reply
If you visit the Keil page, and select Support Resources, and then drill down to File Download Area and ARM Download Files: http://www.keil.com/download/list/arm.htm
Then you will find "Interrupt-Driven UART I/O for Philips LPC2100" http://www.keil.com/download/docs/330.asp
Download this example and try it out. Read the code, and read the datasheet for your processor. Repeat at least two times and then come back if you still have questions.
Thanks for reply ....... I understand your given code...........of example canu help me only reading SMS part in my code ................
seriously its very urgent for me....... plz reply if u want than i will mail u my code......... Thanks ......... give your mail id.........
Wouldn't your teacher be disappointed if you get the full sources to your project? How much would you learn if you get source code instead of spending time figuring out a solution yourself? The main reason for being at school is to learn, but most of the learning requires own work.
Dear Sir Read sms not only our task............. Actually we want to make home automation by this microcontoller ...... its only small part of our project......... its depend on u what u think...... Thanks 4 your advice..........