Compiler error regarding PWM configuration

Hi all,

I'm trying to use the nrf Connect SDK and configure PWM to use in one pin from nordif nrf52DK. The final chip will be the nrf52810. I have configured the builder to use the nrf52dk_nrf52810. I was using the "blinky" example and trying to add a PWM configuration to it. I have this configurations:

prj.conf:

# PWM
CONFIG_PWM=y
CONFIG_PWM_NRFX=y

nrf52dk_nrf52810.overlay:

/ {
    gpiocustom {
        compatible = "gpio-keys";
        gpiocus0: gpiocus_0 {
            gpios = <&gpio0 11 GPIO_ACTIVE_LOW>;
            label = "Custom gpio 11";
        };
        gpiocus1: gpiocus_1 {
            gpios = <&gpio0 12 GPIO_ACTIVE_LOW>;
            label = "Custom gpio 12";
        };
    };

    soc {
        pwm0: pwm@4001c000  {
            compatible = "nordic,nrf-pwm";
            reg = <0x4001c000 0x1000>;
            label = "PWM_0";
            ch0-pin = <22>;
            #pwm-cells = <3>;
        };
    };

    aliases {
        gpiocus0 = &gpiocus0;
        gpiocus1 = &gpiocus1;
        pwm0 = &pwm0;
    };
};

&sw_pwm {
    status = "okay";
    channel-gpios = <&gpio0 23 GPIO_ACTIVE_HIGH>;
};

Anyone can tell me if the sw_pwm needs to be used to generate the pwm? or only with the pwm is enough?

I added this line in the main.c:

#define DT_ALIAS_PWM_0_LABEL DT_ALIAS(pwm0)

And then, when I try to compile I get this error:

In file included from C:\ncs\v2.0.0\zephyr\include\zephyr\devicetree.h:19,
                 from C:\ncs\v2.0.0\zephyr\include\zephyr\arch\arm\aarch32\arch.h:20,
                 from C:\ncs\v2.0.0\zephyr\include\zephyr\arch\cpu.h:19,
                 from C:\ncs\v2.0.0\zephyr\include\zephyr\kernel_includes.h:33,
                 from C:\ncs\v2.0.0\zephyr\include\zephyr\kernel.h:17,
                 from C:\ncs\v2.0.0\zephyr\include\zephyr\zephyr.h:18,
                 from c:\nordics\blinky\src\main.c:7:
../src/main.c: In function 'main':
c:\nordics\blinky\build_2\zephyr\include\generated\devicetree_unfixed.h:4892:36: error: 'DT_N_S_soc_S_pwm_4001c000' undeclared (first use in this function); did you mean 'DT_N_S_soc_S_pwm_4001c000_ORD'?
 4892 | #define DT_N_ALIAS_pwm0            DT_N_S_soc_S_pwm_4001c000
      |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~
C:\ncs\v2.0.0\zephyr\include\zephyr\devicetree.h:2991:24: note: in expansion of macro 'DT_N_ALIAS_pwm0'
 2991 | #define DT_CAT(a1, a2) a1 ## a2
      |                        ^~
C:\ncs\v2.0.0\zephyr\include\zephyr\devicetree.h:213:25: note: in expansion of macro 'DT_CAT'
  213 | #define DT_ALIAS(alias) DT_CAT(DT_N_ALIAS_, alias)
      |                         ^~~~~~
c:\nordics\blinky\src\main.c:20:30: note: in expansion of macro 'DT_ALIAS'
   20 | #define DT_ALIAS_PWM_0_LABEL DT_ALIAS(pwm0)

How can I solve it? Also I have tried the nRF5 SDK and it was really easy to get the PWM working, but I will need to use zephyr to implement a bootloader in the future.

Hope you can help me.

Best regards

Related