Strange behaviour with time interrupt

Hi everyone.
I am trying to write a code to communicate with a reflow oven controller that uses USB CDC.
I have a USB host which uses a PIC24FJ64GB002 programmed as CDC connected to the arduino and I am using the SoftwareSerial library.
The code works fine when I am using it inside the main loop, but not when I am calling it with the interrupt.
I am guessing it has to do with timing, but I can not figure out why and what is wrong.
The delays between the print commands where necessary in order to have a successful response from the controller. Less than (30) it starts misbehaving.
Any Idea what might be the problem with the interrupt? Is the delay time changed within the interrupt?

Here is the code:

#include <SoftwareSerial.h>

int RxPin     = A4;
int TxPin     = A5;

SoftwareSerial mySerial(RxPin, TxPin); // RX, TX

void setup() {

  cli();          // disable global interrupts
  TCCR1A = 0;     // set entire TCCR1A register to 0
  TCCR1B = 0;     // same for TCCR1B
  TCNT1  = 0;     //initialize counter value to 0

  // set compare match register to desired timer count:
  OCR1A = 31248;
  TCCR1B |= (1 << WGM12);
  TCCR1B |= (1 << CS10);
  TCCR1B |= (1 << CS12);
  TIMSK1 |= (1 << OCIE1A);

void loop() {
  // put your main code here, to run repeatedly:


  String response;
  String command;
  char   inChar;
  int    arrayPos = 3;
  int    charPos;
  int    responseLength;
  int    startPos;
  int    endPos;

  command = "AT+GET_DATA";
  response = "";
  charPos = 0;
  while (charPos < 11) {

  while (mySerial.available() > 0) {
    inChar =;
    response += inChar;

having delays and serial communication inside a isr is not advisable.

make ISR as small as possible.

delay does not work inside a isr. so don't use it.

Thanks for the advise. I will alter my code to exclude the time interrupt.

And you certainly can't use String in an ISR! Memory management for String class is not thread-safe.