Mani Yuvan
Member level 1
- Joined
- Jan 18, 2015
- Messages
- 41
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 6
- Location
- Tamilnadu , India
- Activity points
- 321
i try to sent the simple message through gsm modem but nothing to happen .please check the code and give any suggestion please.Im using sim300 module and c18 compiler
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 #include<p18f452.h> #include"H:\RECovery RObot\header files\delay.h" #pragma config OSC=HS, OSCS=OFF # pragma config DEBUG=OFF, LVP=OFF, STVR=OFF #pragma config WDT=OFF #pragma config BOR=OFF, PWRT=ON void gsm_cmd(unsigned char); void tx_data(unsigned char); void gsm_ready(void); unsigned char enter=0X0D; unsigned char end=0X1A; unsigned char b[]={"haiii.."},i; unsigned char format[]={"AT+CMGF=1"}; unsigned char num[]={"AT+CMGS=\"952xxxxxxx\""}; void tx_data(unsigned char c) { while(PIR1bits.TXIF==0); TXREG=c; PIR1bits.TXIF=0; } void gsm_ready() { for(i=0;i<9;i++) { gsm_cmd(format[i]); delay(1); } tx_data(enter); delay(1000); for(i=0;i<20;i++) { gsm_cmd(num[i]); delay(1); } tx_data(enter); delay(1000); } void gsm_cmd(unsigned char c) { if(c!=0x5C) // Not to send '\' cahracter { while(PIR1bits.TXIF==0); TXREG=c; PIR1bits.TXIF=0; } } void main() { TXSTA=0X20; SPBRG=64;//4800 bps for 20 Mhz crystal TXSTAbits.TXEN=1; RCSTAbits.SPEN=1; gsm_ready(); delay(2); for(i=0;i<7;i++) { gsm_cmd(b[i]); delay(1); } tx_data(enter); tx_data(0X1A); delay(1000); }
Last edited by a moderator: