Just realised you're using an Arduino, I did similar to generate a 38kHz output for infrared. This is the code I used,
Code:
// set up Timer 2
TCCR2A = _BV (COM2A0) | _BV(WGM21); // CTC, toggle OC2A on Compare Match
TCCR2B = _BV (CS20); // No prescaler
OCR2A = 207; // compare A register value (210 * clock speed)
// = 13.125 nS , so frequency is 1 / (2 * 13.125) = 38095
I gated it on/off by setting the pin to output(on) or input(off). It's pin 11 on a Nano.
Mike.