将atmega 32代码转换为atmega 16代码

时间:2014-04-24 16:08:53

标签: c embedded atmega atmega16

我的代码用于atmega32微控制器,用于将坐标转换为nmea格式,如何将其转换为atmega16代码。 因为它使用的是atmega32库文件 这段代码是否适用于atmega16或需要进行一些更改....

#include <mega32.h>

// Alphanumeric LCD Module functions
#include <alcd.h>

// Standard Input/Output functions
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <delay.h>
//int space=0;
//char loc[100],data[100];
//int lp=0,dp=0;
char *datapointer;
int checksum;
int q[10],god=0;
//int i,dot=0,k,lat_dec[10],p;
// int lati_dec,lati_before;
//float new_lati_dec;
//int diff,s,arry[10],w,fake_lati_before;
//char a,b;
//int space;
char a,loc[100],temp[20],data[100],aa[100];
long int var,temp_var,sub,diff,mul,temp1_var;
int i,j,k,count,mod,h,o,count1,l,counter,u;
float dist=0;
int power(int k)
{
    int i,ans=1;
    for(i=0;i<k;i++)
    {
          ans=ans*10;
    }
    return(ans);
}
void gps_putsf(char *str,char *arr)
{
char k;
while (k=*str++) putchar(k);
//putsf("56");
//putchar(13);
//putchar(10);
  //space=0;
     datapointer=arr;
   checksum=0;
      //lcd_putsf("a2");


  /* Loop through entire string, XORing each character to the next */
  while (*datapointer != '\0')
  {
    checksum ^= *datapointer;
    datapointer++;
  }
  //    putsf("$GPGGA,130305.0,2529.64237,N,8151.969852,E,1,08,0.94,00499,M,047,M,,*56");
     i=0;
      while(checksum>=16)
      {
      q[i]=checksum%16;
      checksum=checksum/16;
      i++;
      }
      q[i]=checksum;
      //a[i]=checksum%10;
      //i++;
      //checksum=checksum/10;
      //}
      //i=i-1;
      while(i>=0)
      {
      if(q[i]==0)
      putchar('0');
      if(q[i]==1)
      putchar('1');
      if(q[i]==2)
      putchar('2');
      if(q[i]==3)
      putchar('3');
      if(q[i]==4)
      putchar('4');
      if(q[i]==5)
      putchar('5');
      if(q[i]==6)
      putchar('6');
      if(q[i]==7)
      putchar('7');
      if(q[i]==8)
      putchar('8');
      if(q[i]==9)
      putchar('9');
      //putchar(a[i]);
      //}
     // else
     // putchar(a[i]);
      i--;
      }
     // putchar(checksum); */
      putchar(13);
      putchar(10);
      // Place your code her
}

// Declare your global variables here

void main(void)
{
// Declare your local variables here

// Input/Output Ports initialization
// Port A initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTA=0x00;
DDRA=0x00;

// Port B initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTB=0x00;
DDRB=0x00;

// Port C initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTC=0x00;
DDRC=0x00;

// Port D initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTD=0x00;
DDRD=0x00;

// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
// Mode: Normal top=0xFF
// OC0 output: Disconnected
TCCR0=0x00;
TCNT0=0x00;
OCR0=0x00;

// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer1 Stopped
// Mode: Normal top=0xFFFF
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;

// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer2 Stopped
// Mode: Normal top=0xFF
// OC2 output: Disconnected
ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;

// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
// INT2: Off
MCUCR=0x00;
MCUCSR=0x00;

// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x00;

// USART initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART Receiver: On
// USART Transmitter: On
// USART Mode: Asynchronous
// USART Baud Rate: 4800
UCSRA=0x00;
UCSRB=0x18;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x67;

// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
SFIOR=0x00;

// ADC initialization
// ADC disabled
ADCSRA=0x00;

// SPI initialization
// SPI disabled
SPCR=0x00;

// TWI initialization
// TWI disabled
TWCR=0x00;

// Alphanumeric LCD initialization
// Connections specified in the
// Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu:
// RS - PORTB Bit 0
// RD - PORTB Bit 1
// EN - PORTB Bit 2
// D4 - PORTB Bit 4
// D5 - PORTB Bit 5
// D6 - PORTB Bit 6
// D7 - PORTB Bit 7
// Characters/line: 16
lcd_init(16);
lcd_clear();
//lcd_puts("a");
while(1)
{
god++;
//lcd_putsf("C");
   loc[0]=0x24;
      loc[1]=0x47;loc[2]=0x50;loc[3]=0x47;loc[4]=0x47;loc[5]=0x41;loc[6]=0X2C;loc[7]=0X31;loc[8]=0x33;loc[9]=0x30;loc[10]=0x33;loc[11]=0x30;
      loc[12]=0x35;loc[13]=0X2E;loc[14]=0x30;loc[15]=0X2C;
      data[0]=0x47;data[1]=0x50;data[2]=0x47;data[3]=0x47;data[4]=0x41;data[5]=0X2C;data[6]=0X31;data[7]=0x33;data[8]=0x30;data[9]=0x33;data[10]=0x30;
      data[11]=0x35;data[12]=0X2E;data[13]=0x30;data[14]=0X2C;

     // char loc1[]="$GPGGA,130305.0,2529.64237,N,8151.969852,E,1,08,0.94,00499,M,047,M,,*";

     i=16;
     l=15;
    a=getchar();
    while(a!=0X20)
    {
    a=getchar();
    }
      a=getchar();
        a=getchar();
    a=getchar();
      while(a!=0X2E)
      {
      if(a==0X30)
      {
      loc[i]=0X30;
      data[l]=0X30;
      l++;
   //   lcd_putsf("0");
      i++;
      }
         if(a==0X31)
      {
    //   lcd_putsf("1");
      loc[i]=0X31;
      i++;
       data[l]=0X31;
      l++;
      }
         if(a==0X32)
      {
    //   lcd_putsf("2");
      loc[i]=0X32;
      i++;
       data[l]=0X32;
      l++;
      }
         if(a==0X33)
      {
    //   lcd_putsf("3");
      loc[i]=0X33;
      i++;
       data[l]=0X33;
      l++;
      }
         if(a==0X34)
      {
    //   lcd_putsf("4");
      loc[i]=0X34;
      i++;
       data[l]=0X34;
      l++;
      }
         if(a==0X35)
      {
    //   lcd_putsf("5");
      loc[i]=0X35;
      i++;
      data[l]=0X35;
      l++;
      }
         if(a==0X36)
      {
    //   lcd_putsf("6");
      loc[i]=0X36;
      i++;
      data[l]=0X36;
      l++;
      }
         if(a==0X37)
      {
    //   lcd_putsf("7");
      loc[i]=0X37;
      i++;
       data[l]=0X37;
      l++;
      }
         if(a==0X38)
      {
    //   lcd_putsf("8");
      loc[i]=0X38;
      i++;
       data[l]=0X38;
      l++;
      }
         if(a==0X39)
      {
    //   lcd_putsf("9");
      loc[i]=0X39;
       data[l]=0X39;
      l++;
      i++;
      }
      a=getchar();
      }

      j=0;
      if(a==0X2E)
      {
      a=getchar();
      }
      counter=0;
      count1=0;
      while(a!=0X61)
      {
      if(counter<5)
      {
      counter++;
      count1++;
       if(a==0X30)
      {
      temp[j]=0;
      j++;
     // lcd_putsf("0");
      }
         if(a==0X31)
      {
      temp[j]=1;
      j++;
     //  lcd_putsf("1");
      }
         if(a==0X32)
      {

      temp[j]=2;
      j++;
     //  lcd_putsf("2");
      }
         if(a==0X33)
      {
      temp[j]=3;
      j++;
     //  lcd_putsf("3");
      }
         if(a==0X34)
      {
      temp[j]=4;
      j++;
     //  lcd_putsf("4");
      }
         if(a==0X35)
      {
      temp[j]=5;
      j++;
     //  lcd_putsf("5");
      }
         if(a==0X36)
      {
      temp[j]=6;
      j++;
     //  lcd_putsf("6");
      }
         if(a==0X37)
      {
      temp[j]=7;
      j++;
     //  lcd_putsf("7");
      }
         if(a==0X38)
      {
      temp[j]=8;
      j++;
     //  lcd_putsf("8");
      }
         if(a==0X39)
      {
      temp[j]=9;
      j++;
    //   lcd_putsf("9");
      }
      }
      a=getchar();
      }


      j=j-1;
      var =0;
      for(k=j;k>=0;k--)
      {
      var= var+ temp[j-k]*(long)power(k);
      }

      var=var*60;

    temp_var=var;
      count=0;

      while(count1>0)
      {
      temp_var=temp_var/10;
      count++;
      count1--;
      }

     o=0;
     temp1_var=temp_var;
      while(temp1_var!=0)
      {
       temp[o]=temp1_var%10;
       temp1_var=temp1_var/10;
       o++;
      }
      o=o-1;
       for(j=o;j>=0;j--)
      {
         if(temp[j]==0)
      {
      loc[i]=0X30;
    //  lcd_putsf("0");
      i++;
       data[l]=0X30;
      l++;
      }
         if(temp[j]==1)
      {
   //    lcd_putsf("1");
      loc[i]=0X31;
      i++;
       data[l]=0X31;
      l++;
      }
         if(temp[j]==2)
      {
    //   lcd_putsf("2");
      loc[i]=0X32;
      i++;
      data[l]=0X32;
      l++;
      }
      if(temp[j]==3)
      {
   //    lcd_putsf("3");
      loc[i]=0x33;
      i++;
       data[l]=0X33;
      l++;
      }
        if(temp[j]==4)
      {
   //    lcd_putsf("4");
      loc[i]=0X34;
      i++;
       data[l]=0X34;
      l++;
      }
         if(temp[j]==5)
      {
   //    lcd_putsf("5");
      loc[i]=0X35;
      i++;
       data[l]=0X35;
      l++;
      }
         if(temp[j]==6)
      {
   //    lcd_putsf("6");
      loc[i]=0X36;
      i++;
       data[l]=0X36;
      l++;
      }
         if(temp[j]==7)
      {
    //   lcd_putsf("7");
      loc[i]=0X37;
      i++;
       data[l]=0X37;
      l++;
      }
         if(temp[j]==8)
      {
    //   lcd_putsf("8");
      loc[i]=0X38;
      i++;
       data[l]=0X38;
      l++;
      }
         if(temp[j]==9)
      {
    //   lcd_putsf("9");
      loc[i]=0X39;
      i++;
       data[l]=0X39;
      l++;
      }
     }

      loc[i]=0X2E;
       data[l]=0X2E;
      l++;
    //  lcd_putsf(".");
      i++;
     sub=0;
     mul=1;
    for(h=0;h<count;h++)
    {
    mul=mul*10;
    }
      sub=temp_var*mul;

      diff=var-sub;
    //  itoa(diff,c1);
    //  lcd_putsf(" ");
    //  lcd_puts(c1);
    //  lcd_putsf(" ");

      k=0;
        while(diff%10==0)
      {
      diff=diff/10;
    //  mod=diff%10;
      count--;
      }

      while(diff>0)
     {

//    if(diff%10==0)
 //   {
  //  diff=diff/10;
  //  }
  //  else
  //  {
     temp[k]=diff%10;
      diff=diff/10;
      k++;
 //     }
     }
      k=k-1;
   //   itoa(diff,c1);
   //   lcd_putsf(" ");
    // lcd_puts(c1);
    //  lcd_putsf(" ");
    //  itoa(k,c1);
    //  lcd_putsf(" ");
    // lcd_puts(c1);
    //  lcd_putsf(" ");

      for(j=k;j>=0;j--)
      {
         if(temp[j]==0)
      {
      loc[i]=0X30;
   //   lcd_putsf("0");
      i++;
      data[l]=0X30;
      l++;
      }
         if(temp[j]==1)
      {
   //    lcd_putsf("1");
      loc[i]=0X31;
      i++;
       data[l]=0X31;
      l++;
      }
         if(temp[j]==2)
      {
   //    lcd_putsf("2");
      loc[i]=0X32;
      i++;
       data[l]=0X32;
      l++;
      }
      if(temp[j]==3)
      {
   //    lcd_putsf("3");
      loc[i]=0x33;
      i++;
       data[l]=0X33;
      l++;
      }
        if(temp[j]==4)
      {
    //   lcd_putsf("4");
      loc[i]=0X34;
      i++;
       data[l]=0X34;
      l++;
      }
         if(temp[j]==5)
      {
    //   lcd_putsf("5");
      loc[i]=0X35;
      i++;
       data[l]=0X35;
      l++;
      }
         if(temp[j]==6)
      {
    //   lcd_putsf("6");
      loc[i]=0X36;
      i++;
       data[l]=0X36;
      l++;
      }
         if(temp[j]==7)
      {
    //   lcd_putsf("7");
      loc[i]=0X37;
      i++;
       data[l]=0X37;
      l++;
      }
         if(temp[j]==8)
      {
    //   lcd_putsf("8");
      loc[i]=0X38;
      i++;
       data[l]=0X38;
      l++;
      }
         if(temp[j]==9)
      {
   //    lcd_putsf("9");
      loc[i]=0X39;
      i++;
       data[l]=0X39;
      l++;
      }
     }


//for longitude

    // char loc1[]="$GPGGA,130305.0,2529.64237,N,8151.969852,E,1,08,0.94,00499,M,047,M,,*";
     loc[i]=0X2C;
     i++;
      data[l]=0X2C;
      l++;
     loc[i]=0X4E;
     i++;
      data[l]=0X4E;
      l++;
     loc[i]=0X2C;
     i++;
      data[l]=0X2C;
      l++;
     a=getchar();
     while(a!=0X20)
     {
     a=getchar();
     }
     a=getchar();
     while(a!=0X20)
     {
     a=getchar();
     }
     a=getchar();
     a=getchar();
       a=getchar();

      while(a!=0X2E)
      {
      if(a==0X30)
      {
      loc[i]=0X30;
   //   lcd_putsf("0");
      i++;
       data[l]=0X30;
      l++;
      }
         if(a==0X31)
      {
    //   lcd_putsf("1");
      loc[i]=0X31;
      i++;
       data[l]=0X31;
      l++;
      }
         if(a==0X32)
      {
    //   lcd_putsf("2");
      loc[i]=0X32;
      i++;
       data[l]=0X32;
      l++;
      }
         if(a==0X33)
      {
    //   lcd_putsf("3");
      loc[i]=0X33;
      i++;
       data[l]=0X33;
      l++;
      }
         if(a==0X34)
      {
    //   lcd_putsf("4");
      loc[i]=0X34;
      i++;
       data[l]=0X34;
      l++;
      }
         if(a==0X35)
      {
    //   lcd_putsf("5");
      loc[i]=0X35;
      i++;
       data[l]=0X35;
      l++;
      }
         if(a==0X36)
      {
    //   lcd_putsf("6");
      loc[i]=0X36;
      i++;
       data[l]=0X36;
      l++;
      }
         if(a==0X37)
      {
    //   lcd_putsf("7");
      loc[i]=0X37;
      i++;
       data[l]=0X37;
      l++;
      }
         if(a==0X38)
      {
    //   lcd_putsf("8");
      loc[i]=0X38;
      i++;
       data[l]=0X38;
      l++;
      }
         if(a==0X39)
      {
    //   lcd_putsf("9");
      loc[i]=0X39;
      i++;
       data[l]=0X39;
      l++;
      }
      a=getchar();
      }
        j=0;
      if(a==0X2E)
      {
      a=getchar();
      }
        count1=0;
        counter=0;
      while(a!=0X0D)
      {
      if(counter<5)
      {
      count1++;
      counter++;
       if(a==0X30)
      {
      temp[j]=0;
      j++;
     // lcd_putsf("0");
      }
         if(a==0X31)
      {
      temp[j]=1;
      j++;
     // lcd_putsf("1");
      }
         if(a==0X32)
      {

      temp[j]=2;
      j++;
     // lcd_putsf("2");
      }
         if(a==0X33)
      {
      temp[j]=3;
      j++;
    //  lcd_putsf("3");
      }
         if(a==0X34)
      {
      temp[j]=4;
      j++;
    //  lcd_putsf("4");
      }
         if(a==0X35)
      {
      temp[j]=5;
      j++;
    //  lcd_putsf("5");
      }
         if(a==0X36)
      {
      temp[j]=6;
      j++;
    //  lcd_putsf("6");
      }
         if(a==0X37)
      {
      temp[j]=7;
      j++;
    //  lcd_putsf("7");
      }
         if(a==0X38)
      {
      temp[j]=8;
      j++;
     // lcd_putsf("8");
      }
         if(a==0X39)
      {
      temp[j]=9;
      j++;
     // lcd_putsf("9");
      }
      }
      a=getchar();
      }
         j=j-1;
      var =0;
      for(k=j;k>=0;k--)
      {
      var= var+ temp[j-k]*(long)power(k);
      }

      var=var*60;

    temp_var=var;
      count=0;

      while(count1>0)
      {
      temp_var=temp_var/10;
      count++;
      count1--;
      }

     o=0;
     temp1_var=temp_var;
      while(temp1_var!=0)
      {
       temp[o]=temp1_var%10;
       temp1_var=temp1_var/10;
       o++;
      }
      o=o-1;
       for(j=o;j>=0;j--)
      {
         if(temp[j]==0)
      {
      loc[i]=0X30;
   //   lcd_putsf("0");
      i++;
       data[l]=0X30;
      l++;
      }
         if(temp[j]==1)
      {
   //    lcd_putsf("1");
      loc[i]=0X31;
      i++;
       data[l]=0X31;
      l++;
      }
         if(temp[j]==2)
      {
   //    lcd_putsf("2");
      loc[i]=0X32;
      i++;
       data[l]=0X32;
      l++;
      }
      if(temp[j]==3)
      {
   //    lcd_putsf("3");
      loc[i]=0x33;
      i++;
       data[l]=0X33;
      l++;
      }
        if(temp[j]==4)
      {
   //    lcd_putsf("4");
      loc[i]=0X34;
      i++;
       data[l]=0X34;
      l++;
      }
         if(temp[j]==5)
      {
   //    lcd_putsf("5");
      loc[i]=0X35;
      i++;
       data[l]=0X35;
      l++;
      }
         if(temp[j]==6)
      {
   //    lcd_putsf("6");
      loc[i]=0X36;
      i++;
       data[l]=0X36;
      l++;
      }
         if(temp[j]==7)
      {
   //    lcd_putsf("7");
      loc[i]=0X37;
      i++;
       data[l]=0X37;
      l++;
      }
         if(temp[j]==8)
      {
   //    lcd_putsf("8");
      loc[i]=0X38;
      i++;
       data[l]=0X38;
      l++;
      }
         if(temp[j]==9)
      {
   //    lcd_putsf("9");
      loc[i]=0X39;
      i++;
       data[l]=0X39;
      l++;
      }
     }

      loc[i]=0X2E;
       data[l]=0X2E;
      l++;
   //   lcd_putsf(".");
      i++;
     sub=0;
     mul=1;
    for(h=0;h<count;h++)
    {
    mul=mul*10;
    }
      sub=temp_var*mul;

      diff=var-sub;

      k=0;
         while(diff%10==0)
      {
      diff=diff/10;
      mod=diff%10;
      count--;
      }
      while(diff>0)
     {


 //   if(diff%10==0)
  //  {
  //  diff=diff/10;
  //  }
  //  else
  //  {
     temp[k]=diff%10;
      diff=diff/10;
      k++;
    //  }
     }
      k=k-1;
      for(j=k;j>=0;j--)
      {
         if(temp[j]==0)
      {
      loc[i]=0X30;
   //   lcd_putsf("0");
      i++;
       data[l]=0X30;
      l++;
      }
         if(temp[j]==1)
      {
   //    lcd_putsf("1");
      loc[i]=0X31;
      i++;
       data[l]=0X31;
      l++;
      }
         if(temp[j]==2)
      {
   //    lcd_putsf("2");
      loc[i]=0X32;
      i++;
       data[l]=0X32;
      l++;
      }
      if(temp[j]==3)
      {
    //   lcd_putsf("3");
      loc[i]=0x33;
      i++;
       data[l]=0X33;
      l++;
      }
        if(temp[j]==4)
      {
    //   lcd_putsf("4");
      loc[i]=0X34;
      i++;
       data[l]=0X34;
      l++;
      }
         if(temp[j]==5)
      {
    //   lcd_putsf("5");
      loc[i]=0X35;
      i++;
       data[l]=0X35;
      l++;
      }
         if(temp[j]==6)
      {
    //   lcd_putsf("6");
      loc[i]=0X36;
      i++;
       data[l]=0X36;
      l++;
      }
         if(temp[j]==7)
      {
    //   lcd_putsf("7");
      loc[i]=0X37;
      i++;
       data[l]=0X37;
      l++;
      }
         if(temp[j]==8)
      {
    //   lcd_putsf("8");
      loc[i]=0X38;
      i++;
       data[l]=0X38;
      l++;
      }
         if(temp[j]==9)
      {
    //   lcd_putsf("9");
      loc[i]=0X39;
      i++;
       data[l]=0X39;
      l++;
      }
     }

    // char loc1[]="$GPGGA,130305.0,2529.64237,N,8151.969852,E,1,08,0.94,00499,M,047,M,,*";
    loc[i]=0X2C;
    i++;
     data[l]=0X2C;
      l++;
    loc[i]=0X45;
    i++;
     data[l]=0X45;
      l++;
    loc[i]=0X2C;
    i++;
     data[l]=0X2C;
      l++;
    loc[i]=0X31;
    i++;
     data[l]=0X31;
      l++;
    loc[i]=0X2C;
    i++;
     data[l]=0X2C;
      l++;
    loc[i]=0X30;
    i++;
     data[l]=0X30;
      l++;
    loc[i]=0X38;
    i++;
     data[l]=0X38;
      l++;
    loc[i]=0X2C;
    i++;
     data[l]=0X2C;
      l++;
    loc[i]=0X30;
    i++;
     data[l]=0X30;
      l++;
    loc[i]=0X2E;
    i++;
     data[l]=0X2E;
      l++;
    loc[i]=0X39;
    i++;
     data[l]=0X39;
      l++;
    loc[i]=0X34;
    i++;
     data[l]=0X34;
      l++;
    loc[i]=0X2C;
    i++;
     data[l]=0X2C;
      l++;
    loc[i]=0X30;
    i++;
     data[l]=0X30;
      l++;
    loc[i]=0X30;
    i++;
     data[l]=0X30;
      l++;
  // char loc1[]="$GPGGA,130305.0,2529.64237,N,8151.969852,E,1,08,0.94,00499,M,047,M,,*";
    loc[i]=0X34;
    i++;
     data[l]=0X34;
      l++;
    loc[i]=0X39;
    i++;
     data[l]=0X39;
      l++;
    loc[i]=0X39;
    i++;
     data[l]=0X39;
      l++;
    loc[i]=0X2C;
    i++;
     data[l]=0X2C;
      l++;
    loc[i]=0X4D;
    i++;
     data[l]=0X4D;
      l++;
    loc[i]=0X2C;
    i++;
     data[l]=0X2C;
      l++;
    loc[i]=0X30;
    i++;
     data[l]=0X30;
      l++;
    loc[i]=0X34;
    i++;
     data[l]=0X34;
      l++;
    loc[i]=0X37;
    i++;
     data[l]=0X37;
      l++;
    loc[i]=0X2C;
    i++;
     data[l]=0X2C;
      l++;
    loc[i]=0X4D;
    i++;
     data[l]=0X4D;
      l++;
    loc[i]=0X2C;
    i++;
     data[l]=0X2C;
      l++;
    loc[i]=0X2C;
    i++;
     data[l]=0X2C;
      l++;
    loc[i]=0X2A;
    i++;
     data[l]='\0';
     // l++;
    loc[i]='\0';
   // l=0;
   // for(k=1;k<=i-2;k++)
   // {
   // data[l]=data[k];
   // l++;
   // }
   // data[l]='\0';
    //puts(loc);
    //puts(data);
    for(u=1;u<=40;u++)
    {
     gps_putsf(loc,data);
     gps_putsf(loc,data);
    delay_ms(100);
     }
     if(god<=2)
     {
     lcd_gotoxy(0,0);
     lcd_putsf("Dist=0");
     lcd_gotoxy(13,0);
     lcd_putsf("mts");
     }
     if(god>2)
     {
     lcd_gotoxy(0,0);
     lcd_putsf("Dist=");
     dist=dist+11.23;
     ftoa(dist,2,aa);
     lcd_puts(aa);
     lcd_gotoxy(13,0);
     lcd_putsf("mts");
     }


    /* gps_putsf(loc,data);
     gps_putsf(loc,data);
     gps_putsf(loc,data);
     gps_putsf(loc,data);
     gps_putsf(loc,data);
     gps_putsf(loc,data);
     gps_putsf(loc,data);
     gps_putsf(loc,data);
     gps_putsf(loc,data);
     gps_putsf(loc,data);
     gps_putsf(loc,data);
     gps_putsf(loc,data);
     gps_putsf(loc,data);
     gps_putsf(loc,data);
     gps_putsf(loc,data);
     gps_putsf(loc,data);
     gps_putsf(loc,data);
     gps_putsf(loc,data);
     gps_putsf(loc,data);
     gps_putsf(loc,data);*/



     }

}

1 个答案:

答案 0 :(得分:1)

Atmel ATMega16和ATMega32之间的唯一区别是它们的存储空间大小;它们在架构上相同并且共享共同的外围设备。否&#34;转换&#34;除了更改处理器特定的标题之外,它是必要的。