Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only one PWM Channel supported in STM32L4 ? #32429

Closed
alfonsotames opened this issue Feb 18, 2021 · 1 comment
Closed

Only one PWM Channel supported in STM32L4 ? #32429

alfonsotames opened this issue Feb 18, 2021 · 1 comment
Labels
bug The issue is a bug, or the PR is fixing a bug

Comments

@alfonsotames
Copy link

Describe the bug

I don't know if this is a bug or an incomplete implementation. The stm32l432k(b-c)ux-pinctrl.dtsi file located in the stm32 HAL module lists these pin configurations for the timers:

			tim1_ch1n_pa7: tim1_ch1n_pa7 {
				pinmux = <STM32_PINMUX('A', 7, AF1)>;
			};

			tim1_ch1_pa8: tim1_ch1_pa8 {
				pinmux = <STM32_PINMUX('A', 8, AF1)>;
			};

			tim1_ch2_pa9: tim1_ch2_pa9 {
				pinmux = <STM32_PINMUX('A', 9, AF1)>;
			};

			tim1_ch3_pa10: tim1_ch3_pa10 {
				pinmux = <STM32_PINMUX('A', 10, AF1)>;
			};

			tim1_ch4_pa11: tim1_ch4_pa11 {
				pinmux = <STM32_PINMUX('A', 11, AF1)>;
			};

			tim1_ch2n_pb0: tim1_ch2n_pb0 {
				pinmux = <STM32_PINMUX('B', 0, AF1)>;
			};

			tim1_ch3n_pb1: tim1_ch3n_pb1 {
				pinmux = <STM32_PINMUX('B', 1, AF1)>;
			};

			tim2_ch1_pa0: tim2_ch1_pa0 {
				pinmux = <STM32_PINMUX('A', 0, AF1)>;
			};

			tim2_ch2_pa1: tim2_ch2_pa1 {
				pinmux = <STM32_PINMUX('A', 1, AF1)>;
			};

			tim2_ch3_pa2: tim2_ch3_pa2 {
				pinmux = <STM32_PINMUX('A', 2, AF1)>;
			};

			tim2_ch4_pa3: tim2_ch4_pa3 {
				pinmux = <STM32_PINMUX('A', 3, AF1)>;
			};

			tim2_ch1_pa5: tim2_ch1_pa5 {
				pinmux = <STM32_PINMUX('A', 5, AF1)>;
			};

			tim2_ch1_pa15: tim2_ch1_pa15 {
				pinmux = <STM32_PINMUX('A', 15, AF1)>;
			};

			tim2_ch2_pb3: tim2_ch2_pb3 {
				pinmux = <STM32_PINMUX('B', 3, AF1)>;
			};

			tim15_ch1n_pa1: tim15_ch1n_pa1 {
				pinmux = <STM32_PINMUX('A', 1, AF14)>;
			};

			tim15_ch1_pa2: tim15_ch1_pa2 {
				pinmux = <STM32_PINMUX('A', 2, AF14)>;
			};

			tim15_ch2_pa3: tim15_ch2_pa3 {
				pinmux = <STM32_PINMUX('A', 3, AF14)>;
			};

			tim16_ch1_pa6: tim16_ch1_pa6 {
				pinmux = <STM32_PINMUX('A', 6, AF14)>;
			};

			tim16_ch1n_pb6: tim16_ch1n_pb6 {
				pinmux = <STM32_PINMUX('B', 6, AF14)>;
			};

But trying to use anything outside Channel 1 for PWM output doesn't work. No errors reported.

To Reproduce

  1. Configure a devicetree file for an STM32L432KC board (like a Nucleo) with a timer with any channel that's not Channel 1:
/ {
    aliases {
       pwm-led0 = &red_pwm_led;
       red-pwm-led = &red_pwm_led;
    };

    pwmleds {
		compatible = "pwm-leds";
		red_pwm_led: led_pwm_0 {
			pwms = <&pwm0 1 4 PWM_POLARITY_NORMAL>;
		};
    };
}

&timers1 {
	status = "okay";
	pwm0: pwm {
		status = "okay";
		pinctrl-0 = <&tim1_ch3_pa10>;
	};
};
  1. Run the fade_led example in zephyr/samples/basic/fade_led

Expected behavior

  • Fading led in pin PA10

Impact
Only having Channel 1 for timer (maybe other peripherals) limits severely the functionality in many boards.

Environment (please complete the following information):

  • Ubuntu Linux
  • Zephyr OS build v2.5.0-rc1-172-gfd382b4c480b
  • Zephyr SDK
@alfonsotames alfonsotames added the bug The issue is a bug, or the PR is fixing a bug label Feb 18, 2021
@alfonsotames
Copy link
Author

Oh! My error.

I had an error in my DTS:

This line:

pwms = <&pwm0 1 4 PWM_POLARITY_NORMAL>;

Should be:

pwms = <&pwm0 2 4 PWM_POLARITY_NORMAL>;

Second argument is the channel!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug, or the PR is fixing a bug
Projects
None yet
Development

No branches or pull requests

1 participant