"Timer Counter" on XIAO like ATmega boards

Hello.

I’m porting the ATMega328 Arduino project to an XIAO board.
Most projects can be compiled as-is,
I ran into a compilation error in a project.

the source code here;

// frequency adjustment by analog input A1 3520->112640

unsigned int freq;
uint8_t clk;

void setup() {
  TCCR1A = 0b00100001; // TC1 COMPA=low,WGM10
  TCCR1B = 0b00010010; // WGM13, OCR1A PWM, CS11:DIV8 
  TIMSK1 = _BV(OCIE1A); // timer out
  interrupts();
  pinMode(10, OUTPUT);
}
ISR(TIMER1_COMPA_vect) {// TC1->ISR 
     if(clk<32)  clk++;
     else clk=0;
}

void loop(){

  analogWrite(A0, clk); // any DAC

  freq = map(A1,0,1023,3520,112640);
  // Drive TC1
  OCR1A = (unsigned int)(1000000 / (freq));
  OCR1B = (unsigned int)(1000000 / (freq) * 0.5);
}

When I looked up the meaning of “TIMSK” and “OCR” in the original source code, I found that I was probably using timer 1 and internal interrupts, but which instruction would replace it on the XIAO or Samd21 board?
I googled it, but I cant reach the answer.

Can you completely replace this AVR instruction with Samd21, or what if I try to generate 112,640Hz from 3,520Hz on XIAO?
Please help me.

thank you

There are a lot of good examples here: https://www.gammon.com.au/forum/bbshowpost.php?bbtopic_id=123