After trying to do this in Zephyr using NCS v2.2.0 and v2.3.0, I've ended up in confusion and doubt.
Some Dev Zone posts by Torbjørn seem to indicate that I need to use Nordic code to accomplish what I am after
so I am just seeking some clarification. THis is on a custom board using nRF5340 SoC.
The goal, 4 PWM outputs, all same frequency but dynamically updated duty cycles using DMA.
What I know: With STM32 this would be done (roughly) by setting up timers and gpio, set freq, countup and to update dc set new compare.
What I tried to setup in Zephyr I noticed the sys clock is 32K not 16 MHz and that it appears to utilize cpu based a rate monitoring of a loop.
DTS
&pwm0 { status = "okay"; pinctrl-0 = <&pwm0_default>; pinctrl-1 = <&pwm0_sleep>; pinctrl-names = "default", "sleep"; };
Overlay - values\names changed
pwmxout { compatible = "pwm-leds"; pwm_x1: pwm_motor_1 { pwms = <&pwm0 0 PWM_USEC(5000) PWM_POLARITY_NORMAL>; }; pwm_x2: pwm_motor_2 { pwms = <&pwm0 1 PWM_USEC(5000) PWM_POLARITY_NORMAL>; }; pwm_x3: pwm_motor_3 { pwms = <&pwm0 2 PWM_USEC(5000) PWM_POLARITY_NORMAL>; }; pwm_x4: pwm_motor_4 { pwms = <&pwm0 3 PWM_USEC(5000) PWM_POLARITY_NORMAL>; }; };
This would be where my confusion sets in, how to change duty cycle (compare)? Do I call pwm_set_pulse?
AM I better off using nrf code to do this?