Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Wiith SIM908--Please, all pro !!Help me!!Why does it run!

Status
Not open for further replies.

KaitooKid

Newbie level 4
Joined
Mar 22, 2013
Messages
7
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,283
Activity points
1,421
Hi, guys.
I am make boar read longgitude and lattitude from SIM908 by PIC 16f887 and show on LCD.
I simulated on Protues it ran ok,
But when test on boar it didn't run.
I don't understand why does it's run
Please help
thanks a lot!!
This program on PIC:
============================================
#include<16f887.h>
#fuses nowdt,put,hs,noprotect,nolvp,nodebug,nobrownout,nocpd
#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=pin_c6,rcv=pin_c7,bits=8,stop=1)

#define pwr pin_d5
#define rs pin_d6
#define e pin_d7
#define lcd output_b

void command_write(unsigned char cmd);
void data_write(unsigned char data);
void setup_lcd();
void show(unsigned char row,unsigned char colum,char s);
void system();
void gps_lcd();
char timed_getc();

char chuoi[20],kd[11],vd[11],rec[90];
unsigned int td=0;

//in terrupt UART
#INT_RDA
void receive()
{
rec[td]=getc();
td++;
}

//write command on LCD
void command_write(unsigned char cmd)
{
lcd(cmd);
output_low(rs);
output_high(e); delay_ms(5);
output_low(e); delay_ms(5);
}
//write a character on LCD
void data_write(unsigned char data)
{
lcd(data);
output_high(rs);
output_high(e); delay_ms(5);
output_low(e); delay_ms(5);
}
//initialization LCD
void setup_lcd()
{
output_low(e); output_low(rs);
command_write(0x38);
command_write(0x0c);
command_write(0x01);
command_write(0x06);
}
//show on LCD
void show(unsigned char row,unsigned char colum,char s)
{
switch(row)
{
case 1: command_write(0x80+colum);
break;
case 2: command_write(0xc0+colum);
break;
case 3: command_write(0x94+colum);
break;
case 4: command_write(0xd4+colum);
break;
}
while(*s)
{
data_write(*s); s++;
}
}
//=========================================================//
//set config of SIM
/////////////////
void system()
{
char o,k,c,a,l;
//checking activation of SIM if SIM answer "Cal" the same SIM avtived.

do
{
c=getc(); a=getc(); l=getc();
}while((c!='C')||(a!='a')||(l!='l'));

//send "at" to SIM and checking data answer the same "ok"??
do
{
strcpy(chuoi,"WELCOM TO GPS SIM908"); show(4,0,chuoi);
printf("at\r\n"); o=getc();k=getc();
strcpy(chuoi," "); show(4,0,chuoi);
}while((o!='O')||(k!='K'));

//send "at+cmgf=1" to SIM and checking data answer the same "ok"??
do
{
strcpy(chuoi,"CONFIG FORMATING..."); show(4,0,chuoi);
printf("at+cmgf=1\r\n"); o=getc(); k=getc();
strcpy(chuoi," "); show(4,0,chuoi);
}while((o!='O')||(k!='K'));
do

//send "at+cgpspwr=1" to SIM to poweron GPS and checking data answer the same "ok"??
{
strcpy(chuoi,"CONFIG FORMATING..."); show(4,0,chuoi);
printf("at+cgpspwr=1\r\n"); o=getc(); k=getc();
strcpy(chuoi," "); show(4,0,chuoi);
}while((o!='O')||(k!='K'));
do
{
strcpy(chuoi,"CONFIG FORMATING..."); show(4,0,chuoi);
printf("at+cgpsrst=0\r\n"); o=getc(); k=getc();
strcpy(chuoi," "); show(4,0,chuoi);
}while((o!='O')||(k!='K'));

//send "at+sgpsipr=9600" to SIM to initialization baud rate. and checking "ok"
do
{
strcpy(chuoi,"CONFIG FORMATING..."); show(4,0,chuoi);
printf("at+cgpsipr=9600\r\n"); o=timed_getc(); k=timed_getc();
strcpy(chuoi," "); show(4,0,chuoi);
}while((o!='O')||(k!='K'));

//send "at&w" to SIM to save config and checking data answer the same "ok"??
do
{
strcpy(chuoi,"CONFIG FORMATING..."); show(4,0,chuoi);
printf("at&w\r\n"); o=getc(); k=getc();
strcpy(chuoi," "); show(4,0,chuoi);
}while((o!='O')||(k!='K'));
strcpy(chuoi,"LOADING..."); show(4,0,chuoi);
delay_ms(5000);
strcpy(chuoi," "); show(3,0,chuoi);
strcpy(chuoi," "); show(4,0,chuoi);
strcpy(chuoi,"W:");
show(3,0,chuoi);
strcpy(chuoi,"N:");
show(4,0,chuoi);
}

//get longgitude and lattitude
void gps_lcd()
{
unsigned int vt=0,i=0;

while(rec[vt]!=',') {vt++;} //checking "," and deny the frist ","
vt++;
command_write(0x99);
while(rec[vt]!=',') {kd=rec[vt++]; data_write(kd); i++;}//get loggitude and show on LCD
vt++; i=0;
command_write(0xd9);
while(rec[vt]!=',') {vd=rec[vt++]; data_write(vd); i++;}//get lattitude and show on LCD
}

//MAIN
void main()
{
set_tris_b(0x00); set_tris_c(0x80); set_tris_d(0x00);
port_b_pullups(0xff);
setup_lcd();
strcpy(chuoi,"GPS_SIM908");
show(1,0,chuoi);
strcpy(chuoi,"KAITOO KID 908");
show(2,0,chuoi);
output_high(pwr); delay_ms(1000); output_low(pwr);
system();
enable_interrupts(GLOBAL);
enable_interrupts(INT_RDA);
while(true)
{
printf("at+cpgsinf=0\r\n");//read longgitude and lattitude mode 0
gps_lcd(); td=0;
delay_ms(5000);
}
}

Sorry because my bad English.
:sad:
 
Last edited:

Data from SIM send to Microcontroller is ASCII, isn't you??
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top