Go Down

Topic: Compilation Error : Arduino MEGA 2560 with Serial2 and Serial3 (Read 677 times) previous topic - next topic

macburz



Code: [Select]
//***************Myahrs+ Serial3***START**********************************
static char locBuf_s3[ 256 ];
     static unsigned char locPos_s3 = 0;
     char locCH_s3;
     while( Serial3.available() > 0 )
     {  
         locCH_s3 = Serial3.read();
         if( locCH_s3 == ',' )
            locBuf_s3[ locPos_s3++ ] = ' ';
         else if( locCH_s3 != '.' )
            locBuf_s3[ locPos_s3++ ] = locCH_s3;
         if( locCH_s3 == '\n' )
         {
             if( strncmp( locBuf_s3, "$RPY", 4 ) == 0 )
             {
                 locBuf_s3[ locPos_s3 ] = '\0';
                 sscanf( locBuf_s3 + 5, "%d%d%d%d", &SEQ_S3, &ROLL_S3, &PITCH_S3, &YAW_S3 );
             }
             locPos_s3 = 0;
         }
     }
//***************Myahrs+ Serial3****KONIEC*********************************


//***************Myahrs+ Serial2***START**********************************
static char locBuf_s2[ 256 ];
     static unsigned char locPos_s2 = 0;
     char locCH_s2;
     while( Serial2.available() > 0 )
     {  
         locCH_s2 = Serial2.read();
         if( locCH_s2 == ',' )
            locBuf_s2[ locPos_s2++ ] = ' ';
         else if( locCH_s2 != '.' )
            locBuf_s2[ locPos_s2++ ] = locCH_s2;
         if( locCH_s2 == '\n' )
         {
             if( strncmp( locBuf_s2, "$RPY", 4 ) == 0 )
             {
                 locBuf_s2[ locPos_s2 ] = '\0';
                 sscanf( locBuf_s2 + 5, "%d%d%d%d", &SEQ_S2, &ROLL_S2, &PITCH_S2, &YAW_S2 );
             }
             locPos_s2 = 0;
         }
     }
//***************Myahrs+ Serial2****KONIEC*********************************



When I read from only one serial 2 or 3 is corect without any problem.
When I try read together serial2 and serial3 I get compilation error.

I tried to fix this by upgrade my Arduino form 1.6.13 to 1.8.4 but that did not help.


The compilation error I get:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\main.cpp: In function 'main':

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\main.cpp:51:1: error: unable to find a register to spill in class 'NO_REGS'

}

^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\main.cpp:51:1: error: this is the insn:

(insn 1446 1443 1449 130 (set (mem:QI (post_dec:HI (reg/f:HI 32 __SP_L__)) [0  S1 A8])

       (subreg:QI (reg/f:HI 817) 1)) C:\Users\Maciek\Documents\Arduino\Arduino\Antena_test_V1\Antena_test_V1.ino:878 1 {pushqi1}

    (expr_list:REG_ARGS_SIZE (const_int 11 [0xb])

       (nil)))

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\main.cpp:51: confused by earlier errors, bailing out

lto-wrapper: C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-gcc returned 1 exit status

c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ld.exe: error: lto-wrapper failed

collect2.exe: error: ld returned 1 exit status

exit status 1
Błąd kompilacji dla płytki Arduino/Genuino Mega or Mega 2560.






macburz

Thank you weary much.
I will check it asap. ;)  
And it works good ;) I add "__attribute__((__optimize__("O2")));"

Code: [Select]

void komunikacja_Myahrs_serial3 (void) __attribute__((__optimize__("O2")));
void komunikacja_Myahrs_serial2 (void) __attribute__((__optimize__("O2")));

void komunikacja_Myahrs_serial3 (void)
{                     
//***************Myahrs+ Serial3***START**********************************
static char locBuf_s3[ 256 ];
     static unsigned char locPos_s3 = 0;
     char locCH_s3;
     while( Serial3.available() > 0 )
     {   
         locCH_s3 = Serial3.read();
         if( locCH_s3 == ',' )
            locBuf_s3[ locPos_s3++ ] = ' ';
         else if( locCH_s3 != '.' )
            locBuf_s3[ locPos_s3++ ] = locCH_s3;
         if( locCH_s3 == '\n' )
         {
             if( strncmp( locBuf_s3, "$RPY", 4 ) == 0 )
             {
                 locBuf_s3[ locPos_s3 ] = '\0';
                 sscanf( locBuf_s3 + 5, "%d%d%d%d", &SEQ_S3, &ROLL_S3, &PITCH_S3, &YAW_S3 );
             }
             locPos_s3 = 0;
         }
     }
//***************Myahrs+ Serial3****KONIEC*********************************
}
void komunikacja_Myahrs_serial2 (void)
{
//***************Myahrs+ Serial2***START**********************************
static char locBuf_s2[ 256 ];
     static unsigned char locPos_s2 = 0;
     char locCH_s2;
     while( Serial2.available() > 0 )
     {   
         locCH_s2 = Serial2.read();
         if( locCH_s2 == ',' )
            locBuf_s2[ locPos_s2++ ] = ' ';
         else if( locCH_s2 != '.' )
            locBuf_s2[ locPos_s2++ ] = locCH_s2;
         if( locCH_s2 == '\n' )
         {
             if( strncmp( locBuf_s2, "$RPY", 4 ) == 0 )
             {
                 locBuf_s2[ locPos_s2 ] = '\0';
                 sscanf( locBuf_s2 + 5, "%d%d%d%d", &SEQ_S2, &ROLL_S2, &PITCH_S2, &YAW_S2 );
             }
             locPos_s2 = 0;
         }
     }
//***************Myahrs+ Serial2****KONIEC*********************************
}



Go Up