Request NCS v2.1.2 PWM example

Can you please provide an example project showing how to operated a pwn, with the following features:

1) Does NOT use pwm-led, pwn-servo, or whatever drivers or whatever these things are..... Just operate a PWM like one would be manipulating it's registers. No drivers with misleading names (what if the PWM is NOT for LEDS or servos?) and thing that are not properly explained in the sample projects like phandle-arrays.

2) Allows setting of period and duty cycle (pulse)

3) Allows inversion to assigned IO

4) Allows PWM to be shutdown (minimum power state) with pin at logic low

None of the provide examples (blinky_pwm, fade_led, servo_motor, etc) meet all of the above criteria.

Parents
  • Hello,

    I hope you are not too disappointed with my suggestion, because it contains most of the things you clearly stated that you don't want (pwm-led, pwm-servo, etc.)

    I did a hands on course with the nRF52840 DK a while back. While it still uses the pwmleds, and it is intended to control a servo, I believe the guide will cover how to modify it enough for you to call it whatever you like, and you will be able to set both the period and duty cycle as you like. 

    To shut off the PWM, just set the duty cycle to 0. The API will actually turn it off when you do, not just set the duty cycle to 0. 

    You can skip directly to section 3:

    https://github.com/edvinand/OmegaV_BLE_Course#step-3---motor-control

    Best regards,

    Edvin

Reply
  • Hello,

    I hope you are not too disappointed with my suggestion, because it contains most of the things you clearly stated that you don't want (pwm-led, pwm-servo, etc.)

    I did a hands on course with the nRF52840 DK a while back. While it still uses the pwmleds, and it is intended to control a servo, I believe the guide will cover how to modify it enough for you to call it whatever you like, and you will be able to set both the period and duty cycle as you like. 

    To shut off the PWM, just set the duty cycle to 0. The API will actually turn it off when you do, not just set the duty cycle to 0. 

    You can skip directly to section 3:

    https://github.com/edvinand/OmegaV_BLE_Course#step-3---motor-control

    Best regards,

    Edvin

Children
  • Edvin,

    Thank you for your reply. Your example uses the "pwm-leds" dts binding. I want an example that has the same functionality but that uses the "nordic,nrf-pwm" binding. Can you provide that?

    Thank you,

    M. Leung

  • I am not aware of any samples that use that, unfortunately. Why do you need to use this one in particular? The nordic,nrf-pwm (the PWM peripheral) that you refer to is better suited for LED control (ironically) or audio samples. It is well suited if you want to play a sequence that is determined up front. If you want to control something in real time (which it looks like from your requirements list), I suggest you stick to the pwm-leds dts binding. It is more than capable to handle those things.

    BR,

    Edvin

Related