timed interrupt - stop - serial.print?

I am trying to use a timed interrupt to fill an array with ADC values ~400us apart (as an example). I then want to stop the timed interrupts and do a serial print of this array. Any tips on how to do this? I was thinking of something like the following:

int TOP=50; // this sets OCR1A for the CTC counter
int buffSize=60; 
// buff containing the ADC Samps
float* buff;

// Every Arduino program must have a setup section
void setup() {

  Serial.begin(57600);  
  // set compare match register to desired timer count:
  // also known as the TOP
  OCR1A = TOP;
  buff = (float *) malloc(sizeof(float)* buffSize);
  sei();//enable interrupts
}

ISR(TIMER1_COMPA_vect) {
  for (int i= 0 ; i < buffSize - 1 ; i++){
    buff[i] = buff[i+1];
  }
  buff[buffSize - 1] = analogRead(0);
}

void loop() {
  delay(1000);
  cli();
  // Somehow I have to enable the serial print but disable
  // the timed interrupts
  for (int i= 0 ; i < buffSize - 1 ; i++){
    Serial.println(buff[i]);
  }
}

Thanks for the help!

If you are going to create a dynamic array with a fixed size, why won’t a static array work?

ISR(TIMER1_COMPA_vect) {
  for (int i= 0 ; i < buffSize - 1 ; i++){
    buff[i] = buff[i+1];
  }
  buff[buffSize - 1] = analogRead(0);
}

A circular array would stop all that shuffling.

PaulS:
If you are going to create a dynamic array with a fixed size, why won’t a static array work?

ISR(TIMER1_COMPA_vect) {

for (int i= 0 ; i < buffSize - 1 ; i++){
    buff[i] = buff[i+1];
  }
  buff[buffSize - 1] = analogRead(0);
}



A circular array would stop all that shuffling.

I’m not crazy about the shuffling either, but could you give me an example of a circular array? Is it a matter of modifying the index “i” only?

Thanks

Google 'circular buffer'.

PeterH: Google 'circular buffer'.

Will do. Thanks!