help required .... (C function does not return)

Status
Not open for further replies.
heh, i cant seem to get anything on the LCD period!

Code i was testing
Code:
#include <16F877A.h>
#fuses NOWDT,NOLVP,NODEBUG,NOPUT,HS
#use delay(clock=40000000)
#use rs232(baud=9600,rcv=PIN_C7,xmit=PIN_C6)
#include <flexlcd.c>

int loop=0;
char cmd[26];
char ch;
volatile char data[20] ;

void serial(void)
{
  char commaCount = 0;

  char done = 0;
  char count=0;
  char LL;
 
  for(LL=0;LL<2;LL++)     //Loop 2 times for Longitude and Latitude strings
  {
    while(!done)       //Wait until beginning of new printf
    {
      data[0] = getch();
      if(data[0] == '$') done = 1;
    }
    done = 0;
    data[0] = 0;

    while(!done)       //wait until we get out first comma
    {
      data[0] = getch();
      if(data[0] == 0x2C) done = 1;
    }
    done = 0;
    data[0] = 0;

    while(commaCount < 4) // This is the amount of data we need... 4 commas worth
    {
      count=0;            //count variable for placing data in loop
      while(!done)            //loop getting all data possible
      {
        data[count] = getch(); //place data into variable
        count++;               //Increase count
   
        if(data[count] = ',')  //if data is a command break the loop
          done = 1;
      }
      commaCount++;            //Loop is broken so increase the comma count
    }
  }
}

void main(void)
{
  set_tris_c(0b10000000);
  set_tris_D(0x00);
  lcd_init();
  delay_ms(20);

  while(1)
  {
    serial();

  	lcd_gotoxy(1,1);
  	printf(lcd_putc,"LAT=%c%c%c%c%c%c%c%c%c%c%c \n",cmd[1],cmd[2],cmd[3],cmd[4],cmd[5],cmd[6],cmd[7],cmd[8],cmd[9],cmd[10],cmd[11]);
  	lcd_gotoxy(1,2);
  	printf(lcd_putc,"LON=%c%c%c%c%c%c%c%c%c%c%c%c",cmd[13],cmd[14],cmd[15],cmd[16],cmd[17],cmd[18],cmd[19],cmd[20],cmd[21],cmd[22],cmd[23],cmd[24]);
  }
}
 
Even if it did work in ISIS. It probably will not run on real hardware I've seen this happen over and over agin. I have to love the real deal then you know it works LOL
 
Hay Atom when I tried CCS If you look at the built in library when you use lcd_init(); you starting the built in module
 
CCS looks so confusing to me heh. I guess going from C18 to BoostC to Crossworks For ARM to ST Develop to CCS just is too much right now... also i just download a demo of Flowcode.... looks pretty easy to work with. Might use it on any simple rush projects like LED Chaser for a car etc...
 
ohh yes its working
#include <16f877a.h>
#fuses NOWDT,NOLVP,NODEBUG,NOPUT,HS
#use delay(clock=40000000)
//#use rs232(baud=9600,rcv=PIN_C7,xmit=PIN_C6)
#use rs232(baud=9600, xmit=PIN_c6, rcv=PIN_c7, parity=N, bits=8, ERRORS)
#include <flex18.c>
#byte led=6


int loop=0;
char cmd[24];
char ch;
char commaCount = 0;
int x;






serial()
{
delay_ms(50);
loop=0;

while(getch() != 'L');// wait for first "L"
while(getch() != 'L');//wait for 2nd 'L'

while(loop<26)
{
cmd[loop]=getch();// cmd[] have all the info needed
loop++;
}

}





void reset_serial()
{


for(x=0;x<25;x++) cmd[x]=' '; // reset input buffer

}












void main(void)
{
set_tris_a(0x00);
set_tris_b(0x00);
lcd_init();
delay_ms(20);
while(1)
{
loop=0;

led=1;
delay_ms(50);
led=0;
delay_ms(50);
serial();
lcd_gotoxy(1,1);
printf(lcd_putc,"LAT=%c%c%c%c%c%c%c%c%c%c%c \n",cmd[1],cmd[2],cmd[3],cmd[4],cmd[5],cmd[6],cmd[7],cmd[8],cmd[9],cmd[10],cmd[11]);

lcd_gotoxy(1,2);
printf(lcd_putc,"LON=%c%c%c%c%c%c%c%c%c%c%c%c",cmd[13],cmd[14],cmd[15],cmd[16],cmd[17],cmd[18],cmd[19],cmd[20],cmd[21],cmd[22],cmd[23],cmd[24]);
delay_ms(200);
reset_serial();



}
}
 
now i want to calculate distance between two coordinates
i.e c1=N 42 59.458 W 71 27.826
c2=N 43 59.458 W 71 27.826
any body know what to do? i mean mathematics formula.
 
Hah glad to see it works! perhaps it was simply moving the LCD init to before the while loop
 
no its not that i have also modified flexlcd.c to connect lcd control bits on port a because when the loop begins set_tris_c(0b10000000) cause this problem .
RC6(tx) cant be 0 i think ...
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…