atmega timers conversion to teensy

hi guys

as some of you know ive been building a 16bit gaming library that any one can use to build games easily in 16bit color and graphics.

I finally got it to compile with the extra files like the backlight and buttons and so on but now im stuck on the sound file. The problem is that the timers are for atmega and I cant seem to get them working with my teensy.

any one know of way to fix this…

void Sound::begin() {
#if(NUM_CHANNELS > 0)
	prescaler = 1;
	for(byte i=0; i<NUM_CHANNELS; i++){
		chanVolumes[i] = VOLUME_CHANNEL_MAX;
		changeInstrumentSet(defaultInstruments, i); //load default instruments. #0:square wave, #1: noise
		command(CMD_INSTRUMENT, 0, 0, i); //set the default instrument to square wave
	}
	
	analogWrite(3, 1); //lazy version to get the right register settings for PWM (hem)
	TCCR2B = (TCCR2B & B11111000) | 1; //set timer 2 prescaler to 1 -> 30kHz PWM on pin 3

	// initialize timer1 
	noInterrupts(); // disable all interrupts
	TCCR1A = 0;
	TCCR1B = 0;
	TCNT1 = 0;

	OCR1A = 280; // compare match register
	TCCR1B |= (1 << WGM12); // CTC mode
	TCCR1B |= (1 << CS10); // 1 prescaler
	TIMSK1 |= (1 << OCIE1A); // enable timer compare interrupt
	interrupts(); // enable all interrupts
#endif
}

What Teensy are you working with ?

Ian.