PWM with low duty cycle

Is it possible to obtain pulses with a duration of 100 nanoseconds and with a period from 1 Hz to 100 kHz using PWM? I tried PWM2 and with decreasing frequency, the accuracy of the duty cycle decreased.

var freq = 100_000;
var duty = 0.01;
var PWM2 = PwmController.FromName(SC20260.Timer.Pwm.Controller2.Id);
var PWM2_4 = PWM2.OpenChannel(SC20260.Timer.Pwm.Controller2.PA3);
PWM2.SetDesiredFrequency(freq);
PWM2_4.SetActiveDutyCyclePercentage(duty);
PWM2_4.Start();

We are looking into adding signal generator so you can do 100ns but does it need to be exactly 1khz?

do not understand

The CCR register is used to adjust the duty cycle. For timers 2 and 5 it is 32 bit and for other timers it is 16 bit. Therefore, I used timer 2 and hoped for a high accuracy of the duty cycle. But the result is the same as for 16 bit timers. Where is the mistake? Or I’m wrong?

Can the pulse be accurate 100ns but then the low low time changes, like 1khz to 1.2khz? What are using this pulse for?

Also, we try not to think of this as “registers”. You are coding in C# high level. No registers here.

Yes, it is a bug. 1Hz should work on 32 bit.

But a bit more information, you couldn’t get exactly 100ns dutycyle or 1Hz, 10Hz doesn’t work at all?

I am assuming you are using the CCR register to tune the duty cycle.
I get exactly 100ns dutycyle on 100 kHz.
And I couldn’t get exactly 100ns dutycyle on frequencies below 10 kHz.
With decreasing frequency, the accuracy of setting the duty cycle decreases!
On 100 Hz doesn’t work at all