fred
Joined: 04 Mar 2004 Posts: 5
|
Getting iCHIP parameter value over RS232 using PIC16F877 C |
Posted: Tue Jul 13, 2004 1:04 pm |
|
|
Hi,
I am using a PIC16F877 to connect to an iCHIP.
I can't retrive the value of the parameter "webpage"over RS232
It works ok when I use a terminal program using the command
"AT+iwebpage?" and returns "1" I have set the ichip to 9600 baud
//?????????????????????????????????????????????????????????????????
//Can't retrive value 1 over RS232 get nothing so it stays in loop>
//Sends AT+i command"query webpage value" which is 1 over RS232
printf("AT+iwebpage?\r\n");
while (y!='1'){//Wait for 1
y=getc();
}
delay_ms(10000);
//??????????????????????????????????????????????????????????????????
Maybe flushing the RS232 buffer or something?
here is the whole program
#include <16F877.h>
#device *=16
#fuses HS,NOWDT,NOPROTECT,NOLVP,PUT,NOBROWNOUT
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7,stream=ichip) // Jumpers: 8 to 11, 7 to 12
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
long agc,temp,ulpa,dlpa,dlcon,ulcon,dllna,ullna,trigger,control0,webpage;
char alarm[8],ip,x,y,a,b,c,d,e,f,g,h,i,j,k,l,z,m,n,o,p,string[30];
main() {
x=a;
while (true){//#3 wait for alarm
printf("AT+iWWW\r\n");//Sends AT+i command"dial modem" over RS232
while (x!='('){//Wait for char ( in I/(xx.xx.xxx.xx)
x=getc();
}
a=getc();
b=getc();
c=getc();
d=getc();
e=getc();
f=getc();
g=getc();
h=getc();
i=getc();
j=getc();
k=getc();
l=getc();
m=getc();
//****************Sends AT+i command"send e-mail" command over RS232 OK*******************************
printf("AT+iEMA:Go to IP Address (%c%c%c%c%c%c%c%c%c%c%c%c%c \r\n",a,b,c,d,e,f,g,h,i,j,k,l,m);
printf(".\r\n");
delay_ms(10000);
//****************Updates parameter tag "webpage" on website-OK***************************************
printf("AT+iwebpage='1'");
printf("\r\n");
delay_ms(10000);
//?????????????????????????????????????????????????????????????????
//Can't retrive value 1 over RS232
//*************Sends AT+i command"query webpage value" which is 1 over RS232
printf("AT+iwebpage?\r\n");
while (y!='1'){//Wait for 1
y=getc();
}
delay_ms(10000);
//??????????????????????????????????????????????????????????????????
//**************Sends AT+i command"send e-mail" command over RS232**************************
printf("AT+iEMA:webpage= %c \r\n",y);
printf(".\r\n");
delay_ms(10000);
}
}
Thanks for your help |
|