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
| #include<xc.h>
#include<usart.h>
#pragma config PLLDIV = 4, CPUDIV = OSC1_PLL2, FOSC = HS, FCMEN = OFF, IESO = OFF, PWRT = OFF, BOR = ON, BORV = 3, WDT = OFF, WDTPS = 32768
#pragma config MCLRE = ON, LPT1OSC = OFF, PBADEN = ON, CCP2MX = ON, STVREN = ON, LVP = OFF, XINST = OFF, VREGEN = OFF, ICPRT = OFF, DEBUG = ON
#pragma config CP0 = OFF, CP1 = OFF, CP2 = OFF, CP3 = OFF, CPB = OFF, CPD = OFF, WRT0 = OFF, WRT1 = OFF, WRT2 = OFF, WRT3 = OFF
#pragma config WRTB = OFF, WRTC = OFF, WRTD = OFF, EBTR0 = OFF, EBTR1 = OFF, EBTR2 = OFF, EBTR3 = OFF, EBTRB = OFF
void string(unsigned char *s);
unsigned int i=0,j;
unsigned char serial_data;
#define FREQ 20000000 // Frequency = 20MHz
#define baud 9600
#define spbrg_value (((FREQ/64)/baud)-1)
void string(unsigned char *s)
{
while(*s!=0x0)
{
TXREG=*s;
for (j=0;j<100;j++);
while(PIR1bits.TXIF==0)
{
}
PIR1bits.TXIF==0;
s++;
}
}
void tx_data(unsigned char data1)
{
TXREG=data1;
while(PIR1bits.TXIF==0);
PIR1bits.TXIF=0;
}
void d1(void)
{
for (j=0;j<60000;j++);
for (j=0;j<60000;j++);
for (j=0;j<60000;j++);
for (j=0;j<60000;j++);
for (j=0;j<60000;j++);
for (j=0;j<60000;j++);
for (j=0;j<60000;j++);
for (j=0;j<60000;j++);
for (j=0;j<60000;j++);
for (j=0;j<60000;j++);
for (j=0;j<60000;j++);
for (j=0;j<60000;j++);
for (j=0;j<60000;j++);
for (j=0;j<60000;j++);
}
void main(void)
{
TXSTAbits.SYNC=0;
BAUDCONbits.BRG16=0;
TXSTAbits.BRGH=0;
SPBRG=spbrg_value;
RCSTAbits.SPEN=1;
TXSTAbits.TXEN=1;
RCSTAbits.CREN=1;
while(1)
{
string("AT\r\n");
d1(); d1(); d1(); d1();
string("AT+CMGF=1\r\n");
d1(); d1(); d1(); d1();
string("AT+CMGS=\"+91xxxxxxxxxx\"\r\n");
d1(); d1(); d1(); d1();
string("This is my test msg");
d1(); d1(); d1(); d1();
tx_data(0x1A);
d1(); d1(); d1(); d1();
}
} |