Hi,
I have been working on Zephyr for the past weeks and have been able to set multiple GPIOs, interrupts and RF functionnalities. But so far, I thought I could handle the PWMs well, until today. I found out every time I try to set PWM outputs to other pins than the default ones, nothing happened.
To be precise, if I put my LEDs on the default output of the nRF52840 demoboard everything is fine. But nothing happen on any other outputs.
To set things up, I write this fragment of overlay :
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/ {
pwmleds {
pwm_led_0 {
pwms = <&pwm0 17>;
status = "okay";
};
pwm_led1: pwm_led1 {
pwms = <&pwm0 19>;
status = "okay";
};
pwm_led2: pwm_led2 {
pwms = <&pwm0 21>;
status = "okay";
};
pwm_led3: pwm_led3 {
pwms = <&pwm0 23>;
status = "okay";
};
};
aliases {
Then the PWMs are set up in the main.c like this :
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#define PWM_LED0_NODE DT_ALIAS(pwm_led0)
#define PWM_LED1_NODE DT_ALIAS(pwm_led1)
#define PWM_LED2_NODE DT_ALIAS(pwm_led2)
#define PWM_LED3_NODE DT_ALIAS(pwm_led3)
#if DT_NODE_HAS_STATUS(PWM_LED0_NODE, okay)
#define PWM0_CTLR DT_PWMS_CTLR(PWM_LED0_NODE)
#define PWM0_CHANNEL DT_PWMS_CHANNEL(PWM_LED0_NODE)
#define PWM0_FLAGS DT_PWMS_FLAGS(PWM_LED0_NODE)
#else
#error "Unsupported board: pwm-led0 devicetree alias is not defined"
#define PWM0_CTLR DT_INVALID_NODE
#define PWM0_CHANNEL 0
#define PWM0_FLAGS 0
#endif
#if DT_NODE_HAS_STATUS(PWM_LED1_NODE, okay)
#define PWM1_CTLR DT_PWMS_CTLR(PWM_LED1_NODE)
#define PWM1_CHANNEL DT_PWMS_CHANNEL(PWM_LED1_NODE)
#define PWM1_FLAGS DT_PWMS_FLAGS(PWM_LED1_NODE)
#else
I may add that the output pins are indeed changing as the default ones are not working anymore with this configuration.
Best regards,
Charles