Flummoxed

I will put up two pieces of code using TIMER1 in CTC mode. One is in the c style and the other written in Arduino style.

int main(void) {
 
  DDRD |= (1 << PD7);
  TCCR1B |= (1 << WGM12); //Configure Timer1 for CTC
  TIMSK |= (1 << OCIE1A); // Enable CTC interrupt
  sei(); //enable global interrupt
  OCR1A = 15624; // set CTC compare value to 1 Hz at 16 MHz clock and prescalar of 1024
  TCCR1B |= ((1 << CS10) | (1 << CS11));
  for (;;) {
  }
}
ISR(TIMER1_COMPA_vect)  {
  PORTD ^= (1 << PD7);
  
}

This uploads and the Led on PD7 toggles as programmed.
The second code

void setup() {
  // put your setup code here, to run once:
  
  DDRD |= (1 << PD7);//DDR for PD7
  TCCR1B |= (1 << WGM12); //Configure Timer1 for CTC
  TIMSK |= (1 << OCIE1A); // Enable CTC interrupt
  sei();
  
  OCR1A = 15624; // set CTC compare value to 1 Hz at 16 MHz clock and prescalar of 1024
  TCCR1B |= ((1 << CS10) | (1 << CS11));
}
ISR(TIMER1_COMPA_vect)
{
  PORTD ^=(1<<PD7);// Toggle PD7
}
void loop() {
  // put your main code here, to run repeatedly:

}

This code compiles and uploads fine but the Led toggle is missing

Will appreciate clarity in this.
Regards.

When you use the Arduino environment, you enable certain Timer preset values to support the standard PWM outputs controlled with analogWrite(). It is good practice when writing custom Timer1 code to remove all the presets with TCCR1A = 0 and TCCR1B = 0. Your prescalers were wrong for 1024 and were actually at 64.

void setup() {
  // put your setup code here, to run once:
  TCCR1A = 0;
  TCCR1B = 0;
  DDRD |= (1 << PD7);//DDR for PD7
  TCCR1B |= (1 << WGM12); //Configure Timer1 for CTC
  TIMSK1 |= (1 << OCIE1A); // Enable CTC interrupt
  sei();
 
  OCR1A = 15624; // set CTC compare value to 1 Hz at 16 MHz clock and prescalar of 1024
  TCCR1B |= ((1 << CS10) | (1 << CS12));
}
ISR(TIMER1_COMPA_vect)
{
  PORTD ^=(1<<PD7);// Toggle PD7
}
void loop() {
  // put your main code here, to run repeatedly:

}

Thanks a ton, cattledog, clearing the presets is important. You made my day the second time today, appreciate it.

Note: To toggle an output pin:

  PORTD ^= (1<<PD7); // Toggle PD7

can be replaced with:

  PIND = (1<<PD7); // Toggle PD7

This is a hardware feature of AVR output pins and avoids a read/modify/write cycle. The PIN register is the register you use to read input pins. When you write to it, any bit written with a 1 gets toggled and the other bits are left unchanged.

Yes johnwasser,
I am just begining to get a hang of Bit Math, is the reason of experimenting with C type code on the Arduino platform, I use MCUDUDE's minicore.