[SOLVED] Arduino increase PWM Frequency & Control DUTY(for buck-boost converter)

I want increase PWM frequency to 32kHz or 64kHz. I cant make it. May you help me?

//MK


const int pot_pin = A0;
const int feedback = A1;
int pot = 0;
int out = 0;
int vout = 0;
int vpot = 0;
int duty = 1;
int space = 510;
int i=0;

void setup() {
  cli();
  TCCR1A = 0xF2 ;  
  TCCR1B = 0x01 ; 
  TIMSK1 = 0x01 ; 
  ICR1  = 500 ;   
  OCR1A = 125-100 ;  
  OCR1B = 125 ;
  GTCCR = 0x83 ; 
  TCNT1 = 0xFFFF ;  
  GTCCR = 0x00 ; 
  sei(); 
  pinMode(pot_pin, INPUT);
  pinMode(feedback, INPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  Serial.begin(9600);

}

ISR(TIMER1_OVF_vect){
  
 OCR1A=space; //duty
 OCR1B=511-space; //space
}



void loop(){
  
    readpotvout(); 
  
    
    readpotvout();
    
    if(vout < vpot){

      while(vout<vpot){
        duty=duty+4;
        dutyassig();
        delay(50);
        readpotvout();
      }
    }
    else if(vout > vpot){
      
      while(vout>vpot){
        duty=duty-32;
        dutyassig();
        delay(20);
        readpotvout();
      }
    }

    delay(10);
    
}

void dutyassig(){
  
    if(duty>490){
      duty=490;
    }
    else if(duty<10){
      duty=10;
    }
    space=511-duty;
}

void readpotvout(){
    pot = analogRead(pot_pin);
    //vpot= map ( pot , 0, 1023 , 0 , 1023);
    vpot=pot;
    //499=5.0 V
    
    out = analogRead(feedback );
    //vout= map ( out , 0, 1023 , 0 , 1023);
    vout=out;
    //399=40.0 V
    
    if(vpot>820){
      vpot=820;
      
    }
    
}

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

I also changed other codes. If you want to reach my original code you can send message or reply this message

//MK

const int pot_pin = A0;
const int feedback = A1;
int pot = 0;
int out = 0;
int vout = 0;
int vpot = 0;
int duty = 1;
int space = 510;
int i=0;

void setup() {
cli(); // stop interrupts----- interrupt’lari durdurduk
TCCR1A = 0xA2;
TCCR1B = 0x19;
TIMSK1 = 0x01 ; // overflow interrupt
ICR1 = 249 ; // 31.25us cycle time, 32kHz PWM but 64kHz drive pulses (differential)----- frekansi ayarladik
OCR1A = 125-100 ; // example U drive
OCR1B = 125 ;
GTCCR = 0x83 ; // clear and halt prescalers
TCNT1 = 0xFFFF ; // synchronize counters exactly.
GTCCR = 0x00 ; // allow prescalers to fly
sei(); // allow interrupts-----interrut’lari tekrardan baslattik
pinMode(pot_pin, INPUT);
pinMode(feedback, INPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
Serial.begin(9600);

}

ISR(TIMER1_OVF_vect){

OCR1A=duty; //You can set the Duty in here. dutyi buradan ayarla bu kismi silebiliriz.
OCR1B=249-duty;
}

void loop(){

readpotvout();

readpotvout();

if(vout < vpot){

while(vout<vpot){
duty=duty+4;
dutyassig();
delay(50);
readpotvout();
}
}
else if(vout > vpot){

while(vout>vpot){
duty=duty-32;
dutyassig();
delay(20);
readpotvout();
}
}

delay(10);

}

void dutyassig(){

** if(duty>240){**
** duty=240;**
** }**
** else if(duty<20){**
** duty=20;**
** }**

}

void readpotvout(){
pot = analogRead(pot_pin);
//vpot= map ( pot , 0, 1023 , 0 , 1023);
vpot=pot;
//499=5.0 V

out = analogRead(feedback );
//vout= map ( out , 0, 1023 , 0 , 1023);
vout=out;
//399=40.0 V

if(vpot>820){
vpot=820;

}

}