Pinctrl and PWM

Does anyone have an example of using pinctrl and pwm on a Nordic device using Zephyr for a motor driver or something like that?

All the examples appear to NOT use the pinctrl, even though there are messages all over that not using pinctrl is deprecated. Also, they all seem to use pwm-leds, which appears to duplicate the pinctrl information and make pinctrl basically worthless. 

In particular, if I set things up like this:

&pinctrl {
/* boost pwm drive pin */
boost_pwm_default: boost_pwm_default {
group1 {
// Put boost drive output onto LED1 for now
psels = <NRF_PSEL(PWM_OUT0, 0, 14)>;
};
};
/* make sure sleeping does not alter pinout */
boost_pwm_sleep: boost_pwm_sleep {
group1 {
// Put boost drive output onto LED1 for now
psels = <NRF_PSEL(PWM_OUT0, 0, 14)>;
};
};

};

// Get this using a dt label of boostpwm
boostpwm: &pwm0 {
status = "okay";
pinctrl-0 = <&boost_pwm_default>;
pinctrl-1 = <&boost_pwm_sleep>; // make sure sleeping does not change pinout
};

How do I call pwm_pin_set_cycles()? I need to provide it a device controller, a pin, and flags. All the examples use macros that
go through pwm-leds, like DT_PWMS_CTLR, DT_PWMS_CHANNEL and DT_PWMS_FLAGS. But these macros don't appear to work without pwm-leds.
Are there equivalent macros using pinctrl?

Or should I be using a different API?


Parents
  • Hi there,

    Where is it stated that not using pinctrl is deprecated? Maybe you could try to use DEVICE_DT_GET(PWM_DEV_NODE) as in this example?

    regards

    Jared 

  • In zephyr/dts/bindings/pwm/nordic,nrf-pwm.yaml:

    ch0-pin:
    type: int
    required: false
    description: |
    IMPORTANT: This option will only be used if the new pin control driver
    is not enabled. It will be deprecated in the future.

    Note that this phrase:

    IMPORTANT: This option will only be used if the new pin control driver
    is not enabled. It will be deprecated in the future.

    Is in lots of other nordic yaml files. I assume the word IMPORTANT means its important NOW. 

    Also, when I try to define things without pinctrl, I get a warning that pinctrl is on so I MUST use it. I did not turn pinctrl on in my config file. It appears that the file nrf52840dk_nrf52840_defconfig has CONFIG_PINCTRL=y. So Nordic is essentially forcing us to use pinctrl at this point.

Reply
  • In zephyr/dts/bindings/pwm/nordic,nrf-pwm.yaml:

    ch0-pin:
    type: int
    required: false
    description: |
    IMPORTANT: This option will only be used if the new pin control driver
    is not enabled. It will be deprecated in the future.

    Note that this phrase:

    IMPORTANT: This option will only be used if the new pin control driver
    is not enabled. It will be deprecated in the future.

    Is in lots of other nordic yaml files. I assume the word IMPORTANT means its important NOW. 

    Also, when I try to define things without pinctrl, I get a warning that pinctrl is on so I MUST use it. I did not turn pinctrl on in my config file. It appears that the file nrf52840dk_nrf52840_defconfig has CONFIG_PINCTRL=y. So Nordic is essentially forcing us to use pinctrl at this point.

Children
No Data
Related