user4396: I'm trying to send 60 float values via serial. Numbers are provided by an accelerometer and saved in a 240 bytes-long array. The array is sent to a function and these values are then copied in a structure.
The problem
The content of the array is still correct when the function is called. Then, when I copy it in the structure, something wrong happens and data are modified after the 26th float. 
Where does the modification of an array of floats take place?
void sendBuffAcc(float a[])
{
  int stepCont = 1;

  // Prints the content of the globally defined array buffXAccToSend
  Serial.println();      
  for (int i=0;i<sizeBuffAcc;i++)    
  {  
    Serial.print("val: ");
    Serial.print(i);
    Serial.print("    ");
    Serial.println(buffXAccToSend[i]);
  }
  Serial.println();           

  MyShortCommand * pMyCmdShort = (MyShortCommand *)(&bufferAcc[sizeof(MyControlHdr)]);

  for (int i=0;i<sizeBuffAcc;i++)    
  {
    Serial.print("val: ");
    Serial.print(i);
    Serial.print("| Global Array:");
    Serial.println(buffXAccToSend[i]);

    numFilterValuesToSend++;    

    pMyCmdShort->cmd = accValuesID;  
    pMyCmdShort->param1 = a[i];  
    pMyCmdShort->param2 = 0;
    pMyCmdShort->param3 = 0;
    pMyCmdShort->param4 = 0;

    Serial.print("|   Param: ");
    Serial.print(pMyCmdShort->param1);
    Serial.print("|   Array:");
    Serial.println(a[i]);

    // Move the pointer to save data in next positions
    pMyCmdShort++;
  }
  stepCont++;
 }
 storeAccData = false;
 contBuffAcc=1;      
}

First, the content of the global array buffXAccToSend is printed via serial, then the i-th elements of a[i] and the value assigned to the pMyCmdShort->param1. This is the output:
val: 0    -0.00
val: 1    -0.00
val: 2    0.01
val: 3    -0.01
val: 4    0.04
val: 5    0.00
val: 6    0.01
val: 7    0.03
val: 8    0.01
val: 9    -0.00
val: 10    0.00
val: 11    -0.01
val: 12    -0.00
val: 13    0.01
val: 14    -0.02
val: 15    0.03
val: 16    0.00
val: 17    0.02
val: 18    -0.01
val: 19    0.00
val: 20    0.00
val: 21    -0.00
val: 22    -0.01
val: 23    -0.01
val: 24    0.01
val: 25    0.01
val: 26    -0.00
val: 27    0.03
val: 28    -0.01
val: 29    -0.00
val: 30    0.04
val: 31    -0.01
val: 32    0.01

val: 0| Global Array: 0.01|  Param: 0.01|  Array: 0.01
val: 1| Global Array: 0.01|  Param: 0.01|  Array: 0.01
val: 2| Global Array: -0.01|  Param: -0.01|  Array: -0.01
val: 3| Global Array: -0.02|  Param: -0.02|  Array: -0.02
val: 4| Global Array: 0.02|  Param: 0.02|  Array: 0.02
val: 5| Global Array: 0.01|  Param: 0.01|  Array: 0.01
val: 6| Global Array: 0.01|  Param: 0.01|  Array: 0.01
val: 7| Global Array: 0.01|  Param: 0.01|  Array: 0.01
val: 8| Global Array: 0.04|  Param: 0.04|  Array: 0.04
val: 9| Global Array: 0.00|  Param: 0.00|  Array: 0.00
val: 10| Global Array: 0.01|  Param: 0.01|  Array: 0.01
val: 11| Global Array: -0.00|  Param: -0.00|  Array: -0.00
val: 12| Global Array: -0.01|  Param: -0.01|  Array: -0.01
val: 13| Global Array: 0.00|  Param: 0.00|  Array: 0.00
val: 14| Global Array: -0.02|  Param: -0.02|  Array: -0.02
val: 15| Global Array: -0.02|  Param: -0.02|  Array: -0.02
val: 16| Global Array: 0.00|  Param: 0.00|  Array: 0.00
val: 17| Global Array: -0.02|  Param: -0.02|  Array: -0.02
val: 18| Global Array: 0.00|  Param: 0.00|  Array: 0.00
val: 19| Global Array: 0.03|  Param: 0.03|  Array: 0.03
val: 20| Global Array: -0.01|  Param: -0.01|  Array: -0.01
val: 21| Global Array: 0.00|  Param: 0.00|  Array: 0.00
val: 22| Global Array: 0.01|  Param: 0.01|  Array: 0.01
val: 23| Global Array: 0.01|  Param: 0.01|  Array: 0.01
val: 24| Global Array: -0.01|  Param: -0.01|  Array: -0.01
val: 25| Global Array: -0.02|  Param: -0.02|  Array: -0.02
val: 26| Global Array: 0.00|  Param: 0.00|  Array: 0.00
val: 27| Global Array: 0.00|  Param: 0.00|  Array: 0.00
val: 28| Global Array: 0.00|  Param: 0.00|  Array: 0.00
val: 29| Global Array: 0.00|  Param: 0.00|  Array: 0.00
val: 30| Global Array: 0.00|  Param: 0.00|  Array: 0.00
val: 31| Global Array: 0.00|  Param: 0.00|  Array: 0.00
val: 32| Global Array: 0.00|  Param: 0.00|  Array: 0.00

This is the output of avr-size:
   text    data     bss     dec     hex
  55828    3906    2978   62712    f4f8

Is it a memory related problem? 

user368: The ATmega328P has 2kiB of SRAM. Your program uses almost 3kiB. Move strings and constant values into flash.

4396: <p>I'm trying to send 60 float values via serial. Numbers are provided by an accelerometer and saved in a 240 bytes-long array. The array is sent to a function and these values are then copied in a structure.</p>

<p><strong>The problem</strong>
The content of the array is still correct when the function is called. Then, when I copy it in the structure, something wrong happens and data are modified after the 26th float. </p>

<p>Where does the modification of an array of floats take place?</p>

<pre><code>void sendBuffAcc(float a[])
{
  int stepCont = 1;

  // Prints the content of the globally defined array buffXAccToSend
  Serial.println();      
  for (int i=0;i&lt;sizeBuffAcc;i++)    
  {  
    Serial.print("val: ");
    Serial.print(i);
    Serial.print("    ");
    Serial.println(buffXAccToSend[i]);
  }
  Serial.println();           

  MyShortCommand * pMyCmdShort = (MyShortCommand *)(&amp;bufferAcc[sizeof(MyControlHdr)]);

  for (int i=0;i&lt;sizeBuffAcc;i++)    
  {
    Serial.print("val: ");
    Serial.print(i);
    Serial.print("| Global Array:");
    Serial.println(buffXAccToSend[i]);

    numFilterValuesToSend++;    

    pMyCmdShort-&gt;cmd = accValuesID;  
    pMyCmdShort-&gt;param1 = a[i];  
    pMyCmdShort-&gt;param2 = 0;
    pMyCmdShort-&gt;param3 = 0;
    pMyCmdShort-&gt;param4 = 0;

    Serial.print("|   Param: ");
    Serial.print(pMyCmdShort-&gt;param1);
    Serial.print("|   Array:");
    Serial.println(a[i]);

    // Move the pointer to save data in next positions
    pMyCmdShort++;
  }
  stepCont++;
 }
 storeAccData = false;
 contBuffAcc=1;      
}
</code></pre>

<p>First, the content of the global array <code>buffXAccToSend</code> is printed via serial, then the i-th elements of a[i] and the value assigned to the pMyCmdShort->param1. This is the output:</p>

<pre><code>val: 0    -0.00
val: 1    -0.00
val: 2    0.01
val: 3    -0.01
val: 4    0.04
val: 5    0.00
val: 6    0.01
val: 7    0.03
val: 8    0.01
val: 9    -0.00
val: 10    0.00
val: 11    -0.01
val: 12    -0.00
val: 13    0.01
val: 14    -0.02
val: 15    0.03
val: 16    0.00
val: 17    0.02
val: 18    -0.01
val: 19    0.00
val: 20    0.00
val: 21    -0.00
val: 22    -0.01
val: 23    -0.01
val: 24    0.01
val: 25    0.01
val: 26    -0.00
val: 27    0.03
val: 28    -0.01
val: 29    -0.00
val: 30    0.04
val: 31    -0.01
val: 32    0.01

val: 0| Global Array: 0.01|  Param: 0.01|  Array: 0.01
val: 1| Global Array: 0.01|  Param: 0.01|  Array: 0.01
val: 2| Global Array: -0.01|  Param: -0.01|  Array: -0.01
val: 3| Global Array: -0.02|  Param: -0.02|  Array: -0.02
val: 4| Global Array: 0.02|  Param: 0.02|  Array: 0.02
val: 5| Global Array: 0.01|  Param: 0.01|  Array: 0.01
val: 6| Global Array: 0.01|  Param: 0.01|  Array: 0.01
val: 7| Global Array: 0.01|  Param: 0.01|  Array: 0.01
val: 8| Global Array: 0.04|  Param: 0.04|  Array: 0.04
val: 9| Global Array: 0.00|  Param: 0.00|  Array: 0.00
val: 10| Global Array: 0.01|  Param: 0.01|  Array: 0.01
val: 11| Global Array: -0.00|  Param: -0.00|  Array: -0.00
val: 12| Global Array: -0.01|  Param: -0.01|  Array: -0.01
val: 13| Global Array: 0.00|  Param: 0.00|  Array: 0.00
val: 14| Global Array: -0.02|  Param: -0.02|  Array: -0.02
val: 15| Global Array: -0.02|  Param: -0.02|  Array: -0.02
val: 16| Global Array: 0.00|  Param: 0.00|  Array: 0.00
val: 17| Global Array: -0.02|  Param: -0.02|  Array: -0.02
val: 18| Global Array: 0.00|  Param: 0.00|  Array: 0.00
val: 19| Global Array: 0.03|  Param: 0.03|  Array: 0.03
val: 20| Global Array: -0.01|  Param: -0.01|  Array: -0.01
val: 21| Global Array: 0.00|  Param: 0.00|  Array: 0.00
val: 22| Global Array: 0.01|  Param: 0.01|  Array: 0.01
val: 23| Global Array: 0.01|  Param: 0.01|  Array: 0.01
val: 24| Global Array: -0.01|  Param: -0.01|  Array: -0.01
val: 25| Global Array: -0.02|  Param: -0.02|  Array: -0.02
val: 26| Global Array: 0.00|  Param: 0.00|  Array: 0.00
val: 27| Global Array: 0.00|  Param: 0.00|  Array: 0.00
val: 28| Global Array: 0.00|  Param: 0.00|  Array: 0.00
val: 29| Global Array: 0.00|  Param: 0.00|  Array: 0.00
val: 30| Global Array: 0.00|  Param: 0.00|  Array: 0.00
val: 31| Global Array: 0.00|  Param: 0.00|  Array: 0.00
val: 32| Global Array: 0.00|  Param: 0.00|  Array: 0.00
</code></pre>

<p>This is the output of avr-size:</p>

<pre><code>   text    data     bss     dec     hex
  55828    3906    2978   62712    f4f8
</code></pre>

<p>Is it a memory related problem? </p>
 368: <p>The ATmega328P has 2kiB of SRAM. Your program uses almost 3kiB. Move strings and constant values <a href="http://www.arduino.cc/en/Reference/PROGMEM" rel="nofollow">into flash</a>.</p>
