Hi,
I noticed that the blinky_pwm examples only demonstrate PWM control for the pwm_led0 tied to led 1 on the development board. Can you guide me on how to modify the demo to enable PWM control on any pin, and use all four channels?
Hi,
I noticed that the blinky_pwm examples only demonstrate PWM control for the pwm_led0 tied to led 1 on the development board. Can you guide me on how to modify the demo to enable PWM control on any pin, and use all four channels?
Hi Anthony,
I discussed that exact topic in this DevZone question. Could you please refer to it:
Zephyr PWM: pwm_nrfx err -> Invalid channel
Hieu
Hi Anthony,
I discussed that exact topic in this DevZone question. Could you please refer to it:
Zephyr PWM: pwm_nrfx err -> Invalid channel
Hieu
For others who might find it helpful.
Open the file where your nrf sdk is installed:
<path_to_nrf_sdk>\v2.3.0\zephyr\boards\arm\nrf5340dk_nrf5340\nrf5340_cpuapp_common.dts
Make changes to add the 4 channels:
open the pinctrl file
<path_to_nrf_sdk>\v2.3.0\zephyr\boards\arm\nrf5340dk_nrf5340\nrf5340_cpuapp_common-pinctrl.dtsi
and add:
assign the pins where you want PWM to be configured to. I believe any GPIO pin can be configured as a PWM. I have assigned to pin 23,24,29. Pin 28 is default.
If you are using the blinky_pwm examples you can extend it to include all 4 channels by adding:
Thank you!
Hi Anthony,
I appreciate the additional hint for future readers.
While directly modifying the board definition like you are doing is a working approach, I also recommend using overlay files. You can read more about DTS and overlay files here:
https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.3.0/zephyr/build/dts/index.html
Eventually, you will want to use a custom board definition tailored for your product.
Thanks again
Will open another ticket regarding overlays if I run into issues. Thank you!
No problem. Feel free to close this ticket by verifying any answer(s) you deem worked, or I can also close it sometime later.