FrequencyTimer2 interfering with delay()?

I am having a strange problem where I believe that FrequencyTimer2 seems to be interfering with the delay() function. I am using FT2 to perform a shift out on pin4&5 along with toggling pin3 (I also tried other pin combos, including 9&10&12). In my main loop I am using delay(5000) to toggle some data but it (delay()) seems to return immediately. I will post more details later if necessary, but it is late now and I wanted to know if anyone else has seen problems like this. I looked through the FT2 code and did not see anything obvious. Any hints on what to look for in case something else in my program is interfering, would be appreciated. Thanks.

Here is my sample code that I cannot seem to get to work right:

#include "pins_arduino.h"
#include "FrequencyTimer2.cpp"

byte a=1;
int c =0;

extern "C" void myISR(void) {
  if(c >500) {
    if(a) {
      a=0;
      digitalWrite(12, LOW);
    } else {
      a=1;
      digitalWrite(12, HIGH);
    }
    c=0;
  }
  c++;
}

void setup(){
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
  FrequencyTimer2::setPeriod(1000);
  FrequencyTimer2::disable();
  FrequencyTimer2::setOnOverflow(myISR);
}

void loop()
{
  digitalWrite(13, HIGH);
  delay(300);
  digitalWrite(13, LOW);
  delay(700);
}

This should cause the LED on pin 13 to blink at a rate of 1s and the one on pin12 at about a half second. The one on 12 blinks fine, the one on 13 (in the main loop) blinks really fast (strobes). If I comment out FrequencyTimer2 the one on 13 blinks appropriately.

Note: the weird #include “FrequencyTimer2.cpp” is because I haven’t figured out how to compile libraries from the command line (I don’t use the arduino environment).

Any hints?

try declaring a and c as volatile, otherwise the compiler may optimize them out

volatile int c = 0;

Thanks, but that didn't make a difference. a & c are used inside the ISR which seems to be behaving properly timing wise. It's the supposedly independent main loop that is misbehaving, the delay() is not working properly.