hello Nordic
i work with nrf52840, with zephyr (2.6.9)
i have 4 leds on my board that i want to control seperatly with pwm
i put each one of them on a different pwm channel .. following my .dts:
/{... leds { compatible = "gpio-leds"; led0_red: led_0 { gpios = <&gpio1 8 GPIO_ACTIVE_HIGH>; label = "RED_LED_0"; }; led1_orange: led_1 { gpios = <&gpio0 8 GPIO_ACTIVE_HIGH>; label = "ORANGE_LED_1"; }; led2_green: led_2 { gpios = <&gpio0 6 GPIO_ACTIVE_HIGH>; label = "GREEN_LED_2"; }; led3_green2: led_3 { gpios = <&gpio0 30 GPIO_ACTIVE_HIGH>; label = "GREEN_LED_3"; }; }; pwmleds { compatible = "pwm-leds"; pwm_led0_red: pwm_led_0 { pwms = <&pwm0 40>; label = "RED_PWM_LED_0"; }; pwm_led1_orange: pwm_led_1 { pwms = <&pwm0 8>; label = "ORANGE_PWM_LED_1"; }; pwm_led2_green1: pwm_led_2 { pwms = <&pwm0 6>; label = "GREEN_1_PWM_LED_2"; }; pwm_led3_green2: pwm_led_3 { pwms = <&pwm0 30>; label = "GREEN_2_PWM_LED_3"; }; }; aliases { led0-red = &led0_red; led1-orange = &led1_orange; led2-green = &led2_green; led3-green2 = &led3_green2; pwm-led0-red = &pwm_led0_red; pwm-led1-orange = &pwm_led1_orange; pwm-led2-green2 = &pwm_led2_green1; pwm-led3-green1 = &pwm_led3_green2; sw0 = &button0; }; }; &pwm0 { status = "okay"; ch0-pin = <40>; ch1-pin = <8>; ch2-pin = <6>; ch3-pin = <30>; };
added the following to my prj.conf
# PWM Related configs CONFIG_PWM=y CONFIG_LED_PWM=y CONFIG_LED=y
i am following the led_pwm example in the ncs but in the RTT i get the following error :
[00000009] <err> pwm_nrfx: Prescaler for period_cycles 32000000 not found. [00000009] <err> LEDs: err=-22
or this error when i try to blink with 1000 off and 50 on or vice versa
[00000362] <err> pwm_nrfx: Prescaler for period_cycles 16800000 not found. [00000362] <err> LEDs: err=-22
and i see some comment regarding the issue (if i got it right) in pwm_nrfx.c line 125
static int pwm_nrfx_pin_set(const struct device *dev, uint32_t pwm, uint32_t period_cycles, uint32_t pulse_cycles, pwm_flags_t flags) { /* We assume here that period_cycles will always be 16MHz * peripheral clock. Since pwm_nrfx_get_cycles_per_sec() function might * be removed, see ISSUE #6958. * TODO: Remove this comment when issue has been resolved. */...
so what should i predefine or do to avoid that error ?
hope to read from you soon
best regards
Ziv