arunbharathi.arasu
Full Member level 2
- Joined
- Feb 28, 2013
- Messages
- 134
- Helped
- 7
- Reputation
- 14
- Reaction score
- 6
- Trophy points
- 1,298
- Location
- Chennai, Tamil Nadu, India
- Activity points
- 2,151
// PIC18F4550 Configuration Bit Settings
// 'C' source line config statements
#include <htc.h>
//#pragma config CONFIG1L = 0x0
__CONFIG(1, PLLDIV_1 & CPUDIV_OSC1_PLL2 & USBDIV_1);
//#pragma config CONFIG1H = 0x5
__CONFIG(2, FOSC_EC_EC & FCMEN_OFF & IESO_OFF);
//#pragma config CONFIG2L = 0x1F
__CONFIG(3, PWRT_OFF & BOR_ON & BORV_3 & VREGEN_OFF);
//#pragma config CONFIG2H = 0x1E
__CONFIG(4, WDT_OFF & WDTPS_32768);
//#pragma config CONFIG3H = 0x2
__CONFIG(5, CCP2MX_OFF & PBADEN_ON & LPT1OSC_OFF & MCLRE_OFF);
//#pragma config CONFIG4L = 0x80
__CONFIG(6, STVREN_OFF & LVP_OFF & ICPRT_OFF & XINST_OFF);
//#pragma config CONFIG5L = 0xF
__CONFIG(7, CP0_OFF & CP1_OFF & CP2_OFF & CP3_OFF);
//#pragma config CONFIG5H = 0xC0
__CONFIG(8, CPB_OFF & CPD_OFF);
//#pragma config CONFIG6L = 0xF
__CONFIG(9, WRT0_OFF & WRT1_OFF & WRT2_OFF & WRT3_OFF);
//#pragma config CONFIG6H = 0x60
__CONFIG(10, WRTC_OFF & WRTB_OFF & WRTD_ON);
//#pragma config CONFIG7L = 0xF
__CONFIG(11, EBTR0_OFF & EBTR1_OFF & EBTR2_OFF & EBTR3_OFF);
//#pragma config CONFIG7H = 0x40
__CONFIG(12, EBTRB_OFF);
#include "strings.h"
unsigned char ReadData;
void delay(unsigned int de)
{
unsigned int maxde,minde;
for(maxde=0;maxde<de;maxde++)
for(minde=0;minde<453;minde++);
}
void Write_b_eep( unsigned int badd,unsigned char bdat )
{
//EEADR =0x00;
EEADR = (badd & 0x0ff);
EEDATA =bdat;
EECON1bits.EEPGD = 0;
EECON1bits.CFGS = 0;
EECON1bits.WREN = 1;
INTCONbits.GIE = 0;
EECON2 = 0x55;
EECON2 = 0xAA;
EECON1bits.WR = 1;
//while(EECON1bits.WR);
INTCONbits.GIE = 1;
EECON1bits.WREN = 0;
}
unsigned char Read_b_eep( unsigned int badd )
{
EEADR = (badd & 0x0ff);
EECON1bits.CFGS = 0;
EECON1bits.EEPGD = 0;
EECON1bits.RD = 1;
return( EEDATA ); // return with read byte
}
void main(void)
{
port1_init();
UART_init();
trans_string("PIC18F4550 EEPROM");
while(1)
{
Write_b_eep(0x0069,0x0010);
delay(100);
ReadData=Read_b_eep(0x0069);
delay(100);
Write_b_eep(0x006C,ReadData);
delay(1000);
}
}
i could not find any error in my code .
What does "is not possible" mean? --> does the chip explode?But continuously am reading data from different location is not possible.
IP address usually are only 4 bytes. Each with integer values form 0 to 255.IP is Stored Address From 30 to 45
unsigned char x[20],len,i;
void EEPROM_Read_string(unsigned int saddr)
{
i=0;
do
{
x[i]=EEPROM_Read(saddr+i);
i++;
}while(x[i] !='#');
x[i]='\0';
void EEPROM_Write()
{
EECON1bits.WREN = 0;
EECON1bits.EEPGD = 0; //Points to EEPROM
EECON1bits.CFGS = 0; //Points to Flash and EEPROM
EECON1bits.WREN = 1; //EEPROM Write Enable bit
INTCONbits.GIE = 0; //Disable all Interrupts
EECON2 = 0x55;
EECON2 = 0xAA;
EECON1bits.WR = 1; //WR Control bit initiates Write Operation
INTCONbits.GIE = 1;
while(!PIR2bits.EEIF);
PIR2bits.EEIF = 0;
}
void EEPROM_Write_String(unsigned char msg[],unsigned char address)
{
len = strlen(msg);
for(i=0;i<len;i++)
{
EEADR = address + i;
EEDATA = msg[i];
EEPROM_Write();
}
EEADR = address + i;
EEDATA ='#';
EEPROM_Write();
}
unsigned char EEPROM_Read(unsigned int addr)
{
EEADR = addr;
EECON1bits.EEPGD = 0; //Point to EEPROM
EECON1bits.CFGS = 0; //Points to Flash and EEPROM
EECON1bits.RD = 1; //EEPROM Read Enable Bit
return(EEDATA);
}
We can not know if your address is stored as a string.
We can not know what values you read.
We can not know what the EEPROM contents are after writing.
We can not know what your main loop does (how it processes the data)
If you are not interested in giving useful error descriptions, code, expectations, ... I think you are not interested in an answer.
***
Example: "I tried to visit my mother by car. But it's impossible. Please help me."
--> it simply is not enough information .... countless possible problems.
void main()
{
UART_init();
EEPROM_Write_String("49.50.23.181",30);
EEPROM_Read_string(30);
trans_string(x);
while(1);
}
void main()
{
UART_init();
EEPROM_Write_String("49.50.23.181",30);
delay(1000);
EEPROM_Write_String("5201",45);
delay(1000);
EEPROM_Read_string(30);
trans_string(x);
delay(1000);
EEPROM_Read_string(45);
trans_string(x);
while(1);
}
void EEPROM_Read_string(unsigned int saddr)
{
i=0;
do
{
x[i]=EEPROM_Read(saddr+i);
i++;
}while(x[i] !='#');
x[i]='\0';
x[i]=EEPROM_Read(saddr+i);
x[0]=EEPROM_Read(30);
i++;
}while(x[i] !='#');
}while(x[1] !='#');
x[1]=EEPROM_Read(31);
i++;
}while(x[i] !='#');
}while(x[2] !='#');
Please tell us exactely why you know it is caused by the "read function"?When i call the function in second time data will not read properly.
You said this several times.and also serial interrupt will not work.
Are the code a "secret"? or can you post the full code?
// PIC18F2550 Configuration Bit Settings
// 'C' source line config statements
#include <htc.h>
//#pragma config CONFIG1L = 0x0
__CONFIG(1, PLLDIV_1 & CPUDIV_OSC1_PLL2 & USBDIV_1);
//#pragma config CONFIG1H = 0x5
__CONFIG(2, FOSC_EC_EC & FCMEN_OFF & IESO_OFF);
//#pragma config CONFIG2L = 0x1F
__CONFIG(3, PWRT_OFF & BOR_ON & BORV_3 & VREGEN_OFF);
//#pragma config CONFIG2H = 0x1E
__CONFIG(4, WDT_OFF & WDTPS_32768);
//#pragma config CONFIG3H = 0x83
__CONFIG(5, CCP2MX_ON & PBADEN_ON & LPT1OSC_OFF & MCLRE_ON);
//#pragma config CONFIG4L = 0x80
__CONFIG(6, STVREN_OFF & LVP_OFF & XINST_OFF);
//#pragma config CONFIG5L = 0xF
__CONFIG(7, CP0_OFF & CP1_OFF & CP2_OFF & CP3_OFF);
//#pragma config CONFIG5H = 0xC0
__CONFIG(8, CPB_OFF & CPD_OFF);
//#pragma config CONFIG6L = 0xF
__CONFIG(9, WRT0_OFF & WRT1_OFF & WRT2_OFF & WRT3_OFF);
//#pragma config CONFIG6H = 0xE0
__CONFIG(10, WRTC_OFF & WRTB_OFF & WRTD_OFF);
//#pragma config CONFIG7L = 0xF
__CONFIG(11, EBTR0_OFF & EBTR1_OFF & EBTR2_OFF & EBTR3_OFF);
//#pragma config CONFIG7H = 0x40
__CONFIG(12, EBTRB_OFF);
#include<stdio.h>
#include <string.h>
#include"uartgsm.h"
#include"adc.h"
#include "GSM_READ.H"
#include "EEPROM.h"
#define Sw RB1
unsigned char g_bitRxFlag,Rx_data;
unsigned char *arrayptr;
unsigned char *data,msgflag=0,CHECK[10],imeidata[20],clktime[20];
extern unsigned char cmd[20],y[20];
unsigned char Arraydata[160],idata[20],pdata[10];
unsigned int RC_BIT_Flag=0,count=0,count1=0,flag,m=0;
unsigned char *ok="OK",*error="ERROR",*newmsg="+CMTI: \"SM\",1";
void EEPROM_Read_string(unsigned int saddr);
unsigned char EEPROM_Read(unsigned int addr);
void EEPROM_Write_String(unsigned char msg[],unsigned char address);
void port_init()
{
PCFG3=0;
PCFG2=1;
PCFG1=0;
PCFG0=1;
TRISB1=1;
TRISB6=0;
TRISB7=0;
RB6=1;
RB7=0;
}
void delay(unsigned int de)
{
unsigned int maxde,minde;
for(maxde=0;maxde<de;maxde++)
for(minde=0;minde<453;minde++);
}
void interrupt uart_ISR() @ 0x0008
{
if(RCIF == 1)
{
Rx_data=RCREG;
RCIF=0;
if(flag == 1)
{
if(Rx_data!= 0x0A)
{
Arraydata[count]= Rx_data;
count++;
}
else
{
Arraydata[count]='\0';
}
arrayptr=Arraydata;
}
else if(flag == 2)
{
if(Rx_data!= 0x0A)
{
imeidata[count]= Rx_data;
count++;
}
else
{
imeidata[count]='\0';
}
}
else if(flag == 3)
{
if(Rx_data!= 0x0A)
{
clktime[count1]= Rx_data;
count1++;
}
else
{
clktime[count1]='\0';
}
}
else
{
if(Rx_data!= 0x0A)
{
CHECK[count]= Rx_data;
count++;
}
else
{
CHECK[count]=0;
count=0;
}
arrayptr=CHECK;
}
if(strstr(arrayptr,ok))
{
RC_BIT_Flag=1;
}
else if(strstr(arrayptr,error))
{
RC_BIT_Flag=0;
}
else if(strstr(arrayptr,newmsg))
{
msgflag=1;
}
else if(strstr(arrayptr,"ALREADY CONNECT"))
{
RC_BIT_Flag=2;
}
else;
}
}
void SEPARATE()
{
m=-1;
do
{
m++;
idata[m]=EEPROM_Read(30+m);
}while(idata[m] != '#');
idata[m]='\0';
m=-1;
do
{
m++;
pdata[m]=EEPROM_Read(50+m);
}while(pdata[m] != '#');
pdata[m]='\0';
}
void main()
{
port_init();
port1_init();
adc_init();
UART_init();
GSM_INIT();
READ_IMEI();
RB7=1;
SEPARATE();
SET_HTTP(idata,pdata);
while(1)
{
if(msgflag==1)
{
MSG_READ();
count=0;
delay(1000);
msgflag=0;
}
if(RC_BIT_Flag == 0)
{
SET_HTTP(idata,pdata);
}
SEND_SERVER();
delay(1000);
}
}
#ifndef UARTGSM_H
#define UARTGSM_H
#define transmitter RC6
#define rec RC7
extern void delay(unsigned int del);
void port1_init()
{
TRISC6=0;
TRISC7=1;
}
void transmitter_data(unsigned char dat)
{
while(!TRMT);
TXREG=dat;
}
void trans_string(unsigned char *str)
{
while(*str!='\0')
{
transmitter_data(*str);
str++;
delay(100);
}
}
void UART_init()
{
TXEN = 1; // transmission side enable
SYNC = 0; // enable asynchronous bit
BRGH = 1; // enable high baud rate generator
TRMT = 0; // make transmit shift register are full
TX9D = 0; // disable 9bit transmission
SPEN = 1; // enable serial port in receiver side
CREN = 1; // enable continuous reception
ADDEN = 0; // disable address decets bit
FERR = 0; // set no framing error bit
OERR = 0; // set no overrun bit
RX9D = 0; // disble 9bit reception
SPBRG = 129;// load SPBRG value for 9600 baud rate for 20 mhz
GIE = 1;
IPEN = 1;
GIEH = 1;
GIEL = 1;
PEIE = 1;
RCIE = 1;
RCIP = 1;
}
#endif /* UARTGSM_H */
/*
* File: EEPROM.h
* Author: Arun
*
* Created on December 26, 2016, 11:09 AM
*/
#ifndef EEPROM_H
#define EEPROM_H
void EEPROM_Write();
unsigned char EEPROM_Read(unsigned int addr);
void EEPROM_Read_string(unsigned int saddr);
unsigned char x[20],len,i;
void EEPROM_Read_string(unsigned int saddr)
{
i=-1;
do
{
i++;
x[i]=EEPROM_Read(saddr+i);
}while(x[i] !='#');
x[i]='\0';
}
void EEPROM_Write()
{
EECON1bits.WREN = 0;
EECON1bits.EEPGD = 0; //Points to EEPROM
EECON1bits.CFGS = 0; //Points to Flash and EEPROM
EECON1bits.WREN = 1; //EEPROM Write Enable bit
INTCONbits.GIE = 0; //Disable all Interrupts
EECON2 = 0x55;
EECON2 = 0xAA;
EECON1bits.WR = 1; //WR Control bit initiates Write Operation
INTCONbits.GIE = 1;
while(!PIR2bits.EEIF);
PIR2bits.EEIF = 0;
}
void EEPROM_Write_String(unsigned char msg[],unsigned char address)
{
len = strlen(msg);
for(i=0;i<len;i++)
{
EEADR = address + i;
EEDATA = msg[i];
EEPROM_Write();
}
EEADR = address + i;
EEDATA ='#';
EEPROM_Write();
}
unsigned char EEPROM_Read(unsigned int addr)
{
EEADR = addr;
EECON1bits.EEPGD = 0; //Point to EEPROM
EECON1bits.CFGS = 0; //Points to Flash and EEPROM
EECON1bits.RD = 1; //EEPROM Read Enable Bit
return(EEDATA);
}
#endif /* EEPROM_H */
/*
* File: adc.h
* Author: Arun
*
* Created on December 24, 2016, 10:52 AM
*/
#ifndef ADC_H
#define ADC_H
unsigned int ADC_value,ADC_value0,ADC_value1,ADC_value2,ADC_value3,ADC_value4,ADC_value5,ADC_value6,ADC_value7,ADC_value8,ADC_value9,ADC_value10,ADC_value11,ADC_value12, ADC_final;
unsigned int ADC_DATA[10],ADC_DATA1[10],ADC_DATA2[10],ADC_DATA3[10],ADC_DATA4[10],ADC_DATA5[10],ADC_DATA6[10],ADC_DATA7[10],ADC_DATA8[10],ADC_DATA9[10],ADC_DATA10[10],ADC_DATA11[10],ADC_DATA12[10];
extern void delay(unsigned int de);
unsigned int ADC_channe0()
{
CHS0=1;
CHS1=0;
CHS2=0;
CHS3=0;
ADON=1;
GO_DONE=1;
ADC_value=ADRESH;
ADC_value=((ADRESH<<8)|ADRESL);
return ADC_value;
}
unsigned int ADC_channe1()
{
CHS0=0;
CHS1=1;
CHS2=0;
CHS3=0;
ADON=1;
GO_DONE=1;
ADC_value1=ADRESH;
ADC_value1=((ADRESH<<8)|ADRESL);
return ADC_value1;
}
unsigned int ADC_channe2()
{
CHS0=1;
CHS1=1;
CHS2=0;
CHS3=0;
ADON=1;
GO_DONE=1;
ADC_value2=ADRESH;
ADC_value2=((ADRESH<<8)|ADRESL);
return ADC_value2;
}
unsigned int ADC_channe3()
{
CHS0=0;
CHS1=0;
CHS2=1;
CHS3=0;
ADON=1;
GO_DONE=1;
ADC_value3=ADRESH;
ADC_value3=((ADRESH<<8)|ADRESL);
return ADC_value3;
}
unsigned int ADC_channe4()
{
CHS0=1;
CHS1=0;
CHS2=1;
CHS3=0;
ADON=1;
GO_DONE=1;
ADC_value4=ADRESH;
ADC_value4=((ADRESH<<8)|ADRESL);
return ADC_value4;
}
unsigned int ADC_channe5()
{
CHS0=0;
CHS1=1;
CHS2=1;
CHS3=0;
ADON=1;
GO_DONE=1;
ADC_value5=ADRESH;
ADC_value5=((ADRESH<<8)|ADRESL);
delay(100);
return ADC_value5;
}
unsigned int ADC_channe6()
{
CHS0=1;
CHS1=1;
CHS2=1;
CHS3=0;
ADON=1;
GO_DONE=1;
ADC_value6=ADRESH;
ADC_value6=((ADRESH<<8)|ADRESL);
delay(100);
return ADC_value6;
}
unsigned int ADC_channe7()
{
CHS0=0;
CHS1=0;
CHS2=0;
CHS3=1;
ADON=1;
GO_DONE=1;
ADC_value7=ADRESH;
ADC_value7=((ADRESH<<8)|ADRESL);
delay(100);
return ADC_value7;
}
unsigned int ADC_channe8()
{
CHS0=1;
CHS1=0;
CHS2=0;
CHS3=1;
ADON=1;
GO_DONE=1;
ADC_value8=ADRESH;
ADC_value8=((ADRESH<<8)|ADRESL);
delay(100);
return ADC_value8;
}
unsigned int ADC_channe9()
{
CHS0=0;
CHS1=1;
CHS2=0;
CHS3=1;
ADON=1;
GO_DONE=1;
ADC_value9=ADRESH;
ADC_value9=((ADRESH<<8)|ADRESL);
delay(100);
return ADC_value9;
}
unsigned int ADC_channe10()
{
CHS0=0;
CHS1=0;
CHS2=0;
CHS3=0;
ADON=1;
GO_DONE=1;
ADC_value10=ADRESH;
ADC_value10=((ADRESH<<8)|ADRESL);
delay(100);
return ADC_value10;
}
//unsigned int ADC_channe11()
//{
// CHS0=1;
// CHS1=1;
// CHS2=0;
// CHS3=1;
// ADON=1;
// GO_DONE=1;
// ADC_value11=ADRESH;
// ADC_value11=((ADRESH<<8)|ADRESL);
// delay(100);
// return ADC_value11;
//}
//unsigned int ADC_channe12()
//{
// CHS0=0;
// CHS1=0;
// CHS2=1;
// CHS3=1;
// ADON=1;
// GO_DONE=1;
// ADC_value12=ADRESH;
// ADC_value12=((ADRESH<<8)|ADRESL);
// return ADC_value12;
//}
void ADC_VALUE_SEND(unsigned char *name,unsigned char *value)
{
trans_string(name);
trans_string(value);
delay(100);
}
void ADC_READ()
{
ADC_channe0();
sprintf(ADC_DATA,"%d",( ADC_value/85));
ADC_VALUE_SEND("BT0=",ADC_DATA);
delay(100);
ADC_channe1();
sprintf(ADC_DATA1,"%d",( ADC_value1/85));
ADC_VALUE_SEND(",BT1=",ADC_DATA1);
delay(100);
ADC_channe2();
sprintf(ADC_DATA2,"%d",( ADC_value2/85));
ADC_VALUE_SEND(",BT2=",ADC_DATA2);
delay(100);
ADC_channe3();
sprintf(ADC_DATA3,"%d",( ADC_value3/85));
ADC_VALUE_SEND(",BT3=",ADC_DATA3);
delay(100);
ADC_channe4();
sprintf(ADC_DATA4,"%d",( ADC_value4/85));
ADC_VALUE_SEND(",BT4=",ADC_DATA4);
delay(100);
ADC_channe5();
sprintf(ADC_DATA5,"%d",( ADC_value5/85));
ADC_VALUE_SEND(",BT5=",ADC_DATA5);
delay(100);
ADC_channe6();
sprintf(ADC_DATA6,"%d",( ADC_value6/85));
ADC_VALUE_SEND(",BT6=",ADC_DATA6);
delay(100);
ADC_channe7();
sprintf(ADC_DATA7,"%d",( ADC_value7/85));
ADC_VALUE_SEND(",BT7=",ADC_DATA7);
delay(100);
ADC_channe8();
sprintf(ADC_DATA8,"%d",( ADC_value8/85));
ADC_VALUE_SEND(",BT8=",ADC_DATA8);
delay(100);
ADC_channe9();
sprintf(ADC_DATA9,"%d",( ADC_value9/85));
ADC_VALUE_SEND(",BT9=",ADC_DATA9);
delay(100);
ADC_channe10();
sprintf(ADC_DATA10,"%d",( ADC_value10/85));
ADC_VALUE_SEND(",Temp=",ADC_DATA10);
delay(100);
}
void adc_init()
{
ADCS0=0;
ADCS1=0;
ADCS2=0;
ADFM=1;
ACQT2=1;
ACQT1=1;
ACQT0=0;
VCFG1=0;
VCFG0=0;
PCFG3=0;
PCFG2=0;
PCFG1=0;
PCFG0=1;
}
#endif /* ADC_H */
/*
* File: GSM_READ.h
* Author: Arun
*
* Created on December 28, 2016, 11:12 AM
*/
#ifndef GSM_READ_H
#define GSM_READ_H
extern unsigned int RC_BIT_Flag,flag,j=0,count,count1;
extern unsigned char *arrayptr;
extern unsigned char Arraydata[160],imeidata[20],clktime[20];
extern unsigned char *data;
unsigned char num[10],cmd[20],setdata[20],ipnum[10],portnum[10],k=0;
//unsigned char *cmd_check;
unsigned char *imeireq="IMEI,AV2017",*apnset="APN,AV2017",*ipset="IP,AV2017";
//unsigned char data1[80]= "TH+918220882238 @IMEI AV2017 ";
unsigned int step=0;
void EEPROM_Write_String(unsigned char [],unsigned char address);
void MSG_SEND(unsigned char *message);
void SEND_IMEI(unsigned char *imeisend);
void SET_APN(unsigned char *setapn);
void SET_HTTP(unsigned char *inum,unsigned char *pnum);
void SEP_IP_PORT(unsigned char separate[]);
void READ_IMEI();
void ADC_READ();
void GET_TIME();
void CHECK_SMS(unsigned char *sms)
{
trans_string(sms);
delay(1000);
for(k=0;k<=50;k++)
{
if(*sms == '"')
{
sms++;
if(*sms == '+')
{
j=0;
while(*sms != '"')
{
num[j]=*sms;
sms++;j++;
}
k=50;
}
else
sms++;
}
else
sms++;
}
num[j]=0;
sms++;
while(*sms != '#')
{
sms++;
}
sms++;
j=0;
do
{
cmd[j]=*sms;
sms++;
j++;
delay(100);
}while(*sms !='#');
cmd[j]='\0';
sms++;
j=0;
if(*sms == '#')
{
sms++;
do
{
setdata[j]=*sms;
sms++;
j++;
delay(100);
}while(*sms !='#');
setdata[j]='\0';
}
else;
}
void CHECK_CMD(unsigned char *chk)
{
if(strstr(chk,imeireq))
SEND_IMEI(imeidata);
else if(strstr(chk,apnset))
{
EEPROM_Write_String(setdata,0);
SET_APN(setdata);
}
else if(strstr(chk,ipset))
{
j=0;
do
{
ipnum[j]=setdata[j];
j++;
} while(setdata[j] != ',');
ipnum[j]='\0';
EEPROM_Write_String(ipnum,30);
j++;
k=0;
do
{
portnum[k]=setdata[j];
j++;
k++;
}while(setdata[j] != '@');
portnum[k]='\0';
EEPROM_Write_String(portnum,50);
//trans_string(portnum);
trans_string("AT+CMGD=1\r");
SET_HTTP(ipnum,portnum);
}
else if(strstr(chk,"RESET,AV2017"))
{
RB6=0;
delay(1000);
RB6=1;
RESET();
trans_string(chk);
}
else
MSG_SEND("WRONG COMMAND");
}
void SET_HTTP(unsigned char *inum,unsigned char *pnum)
{
trans_string("AT+CIPMUX=0\r");
delay(1000);
while(RC_BIT_Flag != 2)
{
trans_string("AT+CIPSTART=\"TCP\",\"");
trans_string(inum);
trans_string("\",\"");
trans_string(pnum);
trans_string("\"\r");
delay(1000);
}
RC_BIT_Flag=1;
delay(2000);
}
void SEND_SERVER()
{
flag=3;
count1=0;
trans_string("AT+CCLK?\r");
delay(500);
flag=0;
READ_IMEI();
trans_string("AT+CIPSEND\r");
delay(500);
j=0;
while(clktime[j] != '"')
{
j++;
}
j++;
do
{
transmitter_data(clktime[j]);
j++;
delay(100);
}while(clktime[j] != '+');
delay(100);
transmitter_data('#'); //software reading process
j=0;
for(j=1;j<=15;j++)
{
transmitter_data(imeidata[j]);
delay(100);
}
transmitter_data('#'); //software reading process
delay(100);
ADC_READ();
delay(500);
transmitter_data('\x1A');
}
void READ_IMEI()
{
flag=2;
trans_string("AT+GSN\r");
delay(500);
flag=0;
}
void SEND_IMEI(unsigned char *imeisend)
{
trans_string("AT+CMGS=");
transmitter_data('"');
trans_string(num);
transmitter_data('"');
transmitter_data('\r');
delay(100);
for(j=0;j<=19;j++)
{
transmitter_data(*imeisend++);
delay(100);
}
delay(100);
transmitter_data('\x1A');
delay(500);
}
void MSG_READ()
{
flag=1;
trans_string("AT+CMGR=1\r");
delay(500);
CHECK_SMS(arrayptr);
delay(50);
CHECK_CMD(cmd);
flag=0;
delay(2000);
trans_string("AT+CMGD=1\r");
delay(100);
}
void MSG_SEND(unsigned char *message)
{
trans_string("AT+CMGS=");
transmitter_data('"');
trans_string(num);
transmitter_data('"');
transmitter_data('\r');
delay(100);
trans_string(message);
transmitter_data('\x1A');
delay(500);
}
void SET_APN(unsigned char *setapn)
{
trans_string("AT+CGATT=1\r");
delay(1000);
trans_string("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"\r");
delay(1000);
trans_string("AT+SAPBR=3,1,\"APN\",\"");
trans_string(setapn);
transmitter_data('"');
transmitter_data('\r');
delay(1000);
trans_string("AT+SAPBR=1,1\r");
delay(3000);
trans_string("AT+SAPBR=2,1\r");
delay(1000);
MSG_SEND("APN UPDATED");
delay(500);
}
void GSM_INIT()
{
while(step<=6)
{
switch(step)
{
case 0: trans_string("AT\r"); delay(500);break;
case 1: trans_string("ATE0\r");delay(500);break;
case 2: trans_string("AT+CMGF=1\r");delay(500);break;
case 3: trans_string("AT+CNMI=1,1,0,0,0\r");delay(500);break;
case 4: trans_string("AT+CMGD=1\r");delay(500);break;
case 5: trans_string("AT+CLTS=1\r");delay(1000);break;
case 6: trans_string("AT+CTZU=1\r");delay(1000);break;
default: break;
}
delay(500);
if( RC_BIT_Flag==1)
{
RC_BIT_Flag=0;
step++;
}
else if(RC_BIT_Flag==0)
{
step=0;
}
}
}
#endif /* GSM_READ_H */
Please give some idea:
Actually in my project. i used gsm for ADC value is continuously send to the IP.
In between this process if GSM Received any msg, Controller has to read the message and respond. This is requirement.
Actually what happen means. If i am not using ADC , Controller Read message and do the process properly. Process may differ like reply the sms, change APN depends on the incoming message.
But using ADC commends, ADC process will do properly but during this process SERIAL INTERRUPT(to read sms) is not working.
I set SERIAL INTERRUPT as high priority.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?