9160 and pwm output, wrong frequency coming out

nRF Connect SDK 2.1.0

I strugged to get the correct PWM-frequency out with a nRF9160 (nrf9160dk_nrf9160 )dev board.
( I guess the lastest version has many changes...but we would prefer not to change at the moment if possible, usually makes it so difficult each time... )
Anyway, if nRF Connect SDK 2.1.0 is ok for the question...

(FROM the board nrf9160dk_nrf9160 - nrf9160dk_nrf9160_common.dts), all is standard, unmodified
&pwm0 {
status = "okay";
pinctrl-0 = <&pwm0_default>;
pinctrl-1 = <&pwm0_sleep>;
pinctrl-names = "default", "sleep";
};

C-CODE
pwm_dev = DEVICE_DT_GET(DT_NODELABEL(pwm0));
error_code = pwm_set_cycles(pwm_dev, channel, PWM_USEC(1000), PWM_USEC(500), 0);

Measuring with Oscilloscope on pin P0.02 - GND:
I get 16Hz, ie 62.4ms between repetitions.

I'm trying to get 1 kHz, and to very duty cycle 5-95%. Not very close to that so far.


Anyone can see what's wrong?

Related