Get 10khz from arduinoR4wifi

Hi , I bought Arduino R4 WI-FI for my power electronic project , I already used Arduino nano and worked perfectly , but I need use some IOT function so I buy R4 , I used same code and take in consideration PWM pins , my problem is with frequency , for Arduino nano I use this codes line to get 10khz PWM signal

TCCR1A = _BV(COM1A1) | _BV(COM1B1) ; // phase and frequency correct mode. NON-inverted mode
 TCCR1B = _BV(WGM13) | _BV(CS10); //Select mode 8 and select divide by 1 on main clock.
 
 ICR1 = 800;
 PWM = 50;

and no problem with it , but when I try to plug it at Arduino R4 , give me an error , I need a good solution for this problem .

Timer and Counter Control Registers, TCCR1A and TCCR1B are registers in Microchip's ATMega328 microcontroller.
This microcontroller is used by many Arduinos including the Nano and Uno R3.

However the Arduino Uno R4 does not use this microcontroller, it uses an RA4M1 series microcontroller from Renasas.

This microcontroller has completely different registers, that is why your code no longer works.

I found the answer to your problem here.

#include "pwm.h"

PwmOut pwm(D2);

void setup() {    
  pwm.begin(100,0.0);       // period 100µs = 10kHz; pulse 0 µs = 0% 
  pwm.pulse_perc(50.0);     // set 50%
}

void loop() {}

I appreciate your response MR. John, I will check it later, and I will inform you of the result, thank you.

Ok!, The 1st argument is the period of the signal in us. What is the 2nd argument (0.0)?

From pwm.h:

bool begin(float freq_hz, float duty_perc);

It is the duty cycle, so the line following it wasn't strictly necessary.

#include "pwm.h"

PwmOut pwm(D2);

void setup() {    
  pwm.begin(100,30.0);       // period 100µs = 10kHz; duty cycle = 30%  
}

void loop() {}

I did upload the first code and give me an error,

#include "pwm.h"

PwmOut pwm(D2);

void setup() {    
  pwm.begin(100,0.0);       // period 100µs = 10kHz; pulse 0 µs = 0% 
  pwm.pulse_perc(50.0);     // set 50%
}

void loop() {}

So I solve the error by changing the type of numbers to float

#include "pwm.h"

PwmOut pwm(D2);

void setup() {    
  pwm.begin(100.0f,0.0f);       // period 100µs = 10kHz; pulse 0 µs = 0% 
  pwm.pulse_perc(50.0f);     // set 50%
}

void loop() {}

now it works , but the output is 100HZ


so I try to change 100 at the code to 10000 ,

#include "pwm.h"

PwmOut pwm(D2);

void setup() {    
  pwm.begin(10000.0f,50.0f);       // period 100µs = 10kHz; pulse 0 µs = 0% 
  pwm.pulse_perc(50.0f);     // set 50%
}

void loop() {}

then I get 10kHZ


the problem is solved thanks for helping MR.JOHN .