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

pwm_pin_set_cycles is not making PWM signal.

Dear,

As the example code is shown, I have been implementing on LED PWM through nRF53 GPIO0 12. If I set the brightness to 100, it was ON without any issue.  However, if I set the brightness to other values other than 100, the output is zero which is no output.   

So, I think that PWM was not properly generated and the signal is always static to zero or high with brightness 0 or 100.

	err = led_set_brightness(led_pwm, 0, 100);
	if (err < 0) {
		LOG_ERR("err=%d brightness=%d\n", err, 50);
		return;
	}

When I narrowed down led_set_brightness function, this function is calling pwm_pin_set_cycles function which is generating PWM signal. 

I guess that this pwm_pin_set_cycles is not generating PWM excep the static signals like low or high.  

static int led_pwm_set_brightness(const struct device *dev,
				  uint32_t led, uint8_t value)
{
	const struct led_pwm_config *config = DEV_CFG(dev);
	struct led_pwm_data *data = DEV_DATA(dev);
	const struct led_pwm *led_pwm;
	uint32_t pulse;

	if (led >= config->num_leds || value > 100) {
		return -EINVAL;
	}

	led_pwm = &config->led[led];

	pulse = led_pwm->period * value / 100;

	printk("data[led].pwm=%x, led_pwm->channel=%x, led_pwm->period=%x, pulse=%x, led_pwm->flags=%x\n",
		data[led].pwm, led_pwm->channel, led_pwm->period, pulse, led_pwm->flags);

	return pwm_pin_set_cycles(data[led].pwm, led_pwm->channel,
				  led_pwm->period, pulse, led_pwm->flags);
}

Do you have any idea how I can verify pwm_pin_set_cycles to check if working or not?  Is any configuration or setting required before using pwm_pin_set_cycles function?

FYI, my SoC is nRF5340 and DTS is using the configuration following:

	pwmleds {
		compatible = "pwm-leds";
		edge_light: pwm_led_0 {
			pwms = <&pwm0 12>;
			label = "edge-led";
		};
	};

I appreciate any suggestions or ideas in advance if any.

Regards,

Parents Reply Children
No Data
Related