How to enable PWM on PIN Zephyr

Hello All,

I am trying to enable a PWM output on a Seeed Studio Xiao BLE board using Zephyr.

I am aware that this is a Zephyr issue but hopefully I can get some help here:

I am running the PWM blinky Example and I am unable to get it to work:

So far I understand the following:

In the dts I think this is the relevant code:

pwmleds {
		compatible = "pwm-leds";
		pwm_led0: pwm_led_0 {
			pwms = <&pwm0 2 PWM_MSEC(200) PWM_POLARITY_INVERTED>;
		};
	};

in the above: the pwm output is being set on in port 2 which is pin D0 on the xiao board, which will have the period of 200 ms and the polarity is inverted.

I am assuming the comparability line sets what class of interfaces can be run by the PWM led device, but this is not defined any where so how can I find what pwm-leds is?

Furthermore, how would I set the pwm device such that I can output the PWM on a pin in terms of teh configuration I need to do in the device tree?

Any resources that you can link would be awesome. I have found that the zephyr documentation is not obvious what is going on and I think the YouTube videos just gloss over the underlying operational mechanisms.

Thanks in advance.

Hi there,
Nice cut & paste job on the answer without giving an answer. (SPAM), map of portigaull. :face_vomiting:
Let me try. Im not at my desk so this will be short.
For Nrf and Zephyr it seems complex but really isn’t once you get how the parts (files system) works.
The Device tree ,defines the hardware base of the SOC.
Your overlay sets the devices and type of devices you want to interact with or define as what you are using them for in your case its the PWM’s. The device tree defines how many you have available from the SOC (4)?
You can customize how it works and parameters with an Overlay file . I have a link to the best explanation of it. But
Lms if i can locate it.
I’ll edit the post.
There is a pwm blinky example, if you load that up you could see the DTS, and the dsti (i) is include.
Then the overlay. For tge nRF52840 DK.
It pwm speed controls the led faster and slower, with button press. I have a demo on here of it running.
HTH
GL :smile: PJ
:v:

Found it , go watch this it was very helpful.