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

PWM on nRF52840 GPIO with Zephyr

Hello, guys.

We are have nRF52840DK board and Zephyr NCS 1.4.2 development environment.

I am trying to include two PWM channels in the code and control them independently through Zephyr PWM drivers and pwm_pin_set_usec() function.

Everything seems to be OK as long as I select one of the LED GPIOs on DK board (13, 14, 15, or 16) for PWM GPIOs.

However, we want to use some other GPIO for for PWM signals because we want do drive DRV8837 motor controller with them.

Here is what I put in my nrf52840dk_nrf52840.overlay file:

/ {
	model = "Nordic nRF52840 DK NRF52840";
	compatible = "nordic,nrf52840-dk-nrf52840";


	pwmdrv {
		compatible = "pwm-leds";		
		pwm_drv8837p: pwm_drv8837_p {
			pwms = <&pwm0 14>;
		};
		pwm_drv8837n: pwm_drv8837_n {
			pwms = <&pwm1 15>;
		};		
	};


	/* These aliases are provided for compatibility with samples */
	aliases {
		adcctrl = &adc;
		pwm-drv8837p = &pwm_drv8837p;
		pwm-drv8837n = &pwm_drv8837n;
	};
};


&pwm0 {
	status = "okay";
	ch0-pin = <14>;
	ch0-inverted;
};

&pwm1 {
	status = "okay";
	ch1-pin = <15>;
	ch1-inverted;
};
	

As I said, PWMs are working only for GPIOs 13, 14, 15, and 16. When I set GPIO 0 for &pwm0, for example, we don't get PWM signal on P0.0 output.

What we are missing here?

Thanks in advance for your time and efforts.

Sincerely,

Bojan.

Related