This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Using PWM with Zephyr V2.6.0

Heija Guys,

I have a problem with my PWM. I started with the zephyr version 2.4.99 and switched, after we discovered a bug (Link to ticket: https://devzone.nordicsemi.com/f/nordic-q-a/77151/arbitrary-assert-with-extended-advertising). In the newer Version V2.6.0 the "DT_PWMS_LABEL" Macro is deprecated, the changelog mentions, that we should use the "DT_PWMS_CTLR" Macro.

Currently I get the following message before trying to compile the project:

LED_NODE is defined as follows:

pwm_led_tx is defined as follows:

After compilation I have the following output:


In file included from C:/Tools/ncs/v1.5.1/zephyr/include/devicetree.h:19,
                 from C:/Tools/ncs/v1.5.1/zephyr/include/arch/arm/aarch32/arch.h:20,
                 from C:/Tools/ncs/v1.5.1/zephyr/include/arch/cpu.h:19,
                 from C:/Tools/ncs/v1.5.1/zephyr/include/kernel_includes.h:33,
                 from C:/Tools/ncs/v1.5.1/zephyr/include/kernel.h:17,
                 from C:/Tools/ncs/v1.5.1/zephyr/include/init.h:11,
                 from C:/Tools/ncs/v1.5.1/zephyr/include/device.h:29,
                 from C:/Tools/ncs/v1.5.1/zephyr/include/drivers/pwm.h:27,
                 from ../src/hal/HalPwmCtrlConfig.c:4:
zephyr/include/generated/devicetree_unfixed.h:1485:53: error: 'DT_N_S_sw_pwm' undeclared here (not in a function); did you mean 'DT_N_S_sw_pwm_ORD'?
 1485 | #define DT_N_S_pwmleds_S_pwm_led_tx_P_pwms_IDX_0_PH DT_N_S_sw_pwm
      |                                                     ^~~~~~~~~~~~~
C:/Tools/ncs/v1.5.1/zephyr/include/devicetree.h:2334:41: note: in expansion of macro 'DT_N_S_pwmleds_S_pwm_led_tx_P_pwms_IDX_0_PH'
 2334 | #define DT_CAT6(a1, a2, a3, a4, a5, a6) a1 ## a2 ## a3 ## a4 ## a5 ## a6
      |                                         ^~
C:/Tools/ncs/v1.5.1/zephyr/include/devicetree.h:1159:2: note: in expansion of macro 'DT_CAT6'
 1159 |  DT_CAT6(node_id, _P_, prop, _IDX_, idx, _PH)
      |  ^~~~~~~
C:/Tools/ncs/v1.5.1/zephyr/include/devicetree/pwms.h:133:2: note: in expansion of macro 'DT_PHANDLE_BY_IDX'
  133 |  DT_PHANDLE_BY_IDX(node_id, pwms, idx)
      |  ^~~~~~~~~~~~~~~~~
C:/Tools/ncs/v1.5.1/zephyr/include/devicetree/pwms.h:172:31: note: in expansion of macro 'DT_PWMS_CTLR_BY_IDX'
  172 | #define DT_PWMS_CTLR(node_id) DT_PWMS_CTLR_BY_IDX(node_id, 0)
      |                               ^~~~~~~~~~~~~~~~~~~
../src/hal/HalPwmCtrlConfig.c:19:5: note: in expansion of macro 'DT_PWMS_CTLR'
   19 |     DT_PWMS_CTLR(LED_NODE),
      |     ^~~~~~~~~~~~
C:/Tools/ncs/v1.5.1/zephyr/include/devicetree.h:2326:24: note: in expansion of macro 'DT_N_NODELABEL_pwm_led_tx'
 2326 | #define DT_CAT(a1, a2) a1 ## a2
      |                        ^~
C:/Tools/ncs/v1.5.1/zephyr/include/devicetree.h:173:29: note: in expansion of macro 'DT_CAT'
  173 | #define DT_NODELABEL(label) DT_CAT(DT_N_NODELABEL_, label)
      |                             ^~~~~~
../src/hal/HalPwmCtrlConfig.c:10:19: note: in expansion of macro 'DT_NODELABEL'
   10 | #define LED_NODE  DT_NODELABEL(pwm_led_tx)
      |                   ^~~~~~~~~~~~
../src/hal/HalPwmCtrlConfig.c:19:18: note: in expansion of macro 'LED_NODE'
   19 |     DT_PWMS_CTLR(LED_NODE),
      |                  ^~~~~~~~
[121/222] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/crc32_sw.c.obj
ninja: build stopped: subcommand failed.
The terminal process "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command ninja" terminated with exit code: 1.

What am I missing?

Thank you in advance for any help or tip.

Best Regards,

Marc

Parents
  • My Co-Worker found a solution to this. The Problem is, that DT_PWMS_CTLR does not return a label, but a node identifier. This means in my example it "only returns" something like DT_N_S_sw_pwm and that is not defined. I need the value behind "DT_N_S_sw_pwm_P_label", found in devicetree_unfixed.h. That value then is "SW_PWM", the label I need.

    If I then modify DT_PWMS_CTLR(LED_NODE) to DT_LABEL(DT_PWMS_CTLR(LED_NODE)) the problem is fixed.

    Best Regards,

    Marc

Reply
  • My Co-Worker found a solution to this. The Problem is, that DT_PWMS_CTLR does not return a label, but a node identifier. This means in my example it "only returns" something like DT_N_S_sw_pwm and that is not defined. I need the value behind "DT_N_S_sw_pwm_P_label", found in devicetree_unfixed.h. That value then is "SW_PWM", the label I need.

    If I then modify DT_PWMS_CTLR(LED_NODE) to DT_LABEL(DT_PWMS_CTLR(LED_NODE)) the problem is fixed.

    Best Regards,

    Marc

Children
No Data
Related