something wrong with my output (pwm arduino)

Hi.. i need help.. i have the coding as shown below, but its not working as what i expected.. base on what i know, the coding below should provide me a 2MHz frecuency at output pin 9 and 1kHz at ouput pin 8.. but when i test it with oscilloscope i only obtain 2kHz at output pin 9.. what should i do to obtain 2MHz at output pin 9?? how can i change/modified the code?? many2 thankz..

#include <util/delay.h>
int rog = 8;
void setup() {
  pinMode(9, OUTPUT);
  pinMode(rog, OUTPUT);
  
  TCCR1A = 0;
  TCCR1B = 0;
  
  TCCR1A |= _BV(WGM11) | _BV(COM1A1);
  TCCR1B |= _BV(WGM12) | _BV(WGM13) | _BV(CS10) | _BV(ICNC1);

  ICR1= 7;

  OCR1A = 3;
}

void loop(){
delayrog(); 

}

void delayrog(){
   while (1)
	{
		
  digitalWrite(rog, HIGH);
  _delay_ms(0.52);
  digitalWrite(rog, LOW);
  _delay_ms(0.52);
  
	}
}

Processor?

haneys:

   while (1)
{	

digitalWrite(rog, HIGH);
      _delay_ms(0.52);
       digitalWrite(rog, LOW);
       _delay_ms(0.52);
}}

I don't think you will get 1 kHz out of that. i kHz would be a total of 1.0 millisecond delay. Since your are inserting 1.4 milliseconds of delay AND the digitalWrite() calls take time AND the loop has some overhead I would expect a frequency somewhat below 833 Hz.

yup i notice that,tq2.. but, why i can get 2Mz at output pin 9 when i only use code below, but when i add up another output at pin 8 i wont get 2Mz at output pin 9.. i found this weird.. help me..

void setup() {
  pinMode(9, OUTPUT);
  
  TCCR1A = 0;
  TCCR1B = 0;
  
  TCCR1A |= _BV(WGM11) | _BV(COM1A1);
  TCCR1B |= _BV(WGM12) | _BV(WGM13) | _BV(CS10) | _BV(ICNC1);

  ICR1= 7;

  OCR1A = 3;
}

void loop(){

}

Why are you turning on the Input Capture Noise Canceler (ICNC1)?