is it possible to change the default led on a raspberry pico as pwm led and assign it to any other gpio pins . default led is at gpio 25 but the device tree for pwm_led is this : / { leds { compatible = "gpio-leds"; led0: led_0 { gpios = ; label = "LED"; }; }; pwm_leds { compatible = "pwm-leds"; status = "okay"; pwm_led0: pwm_led_0 { pwms = ; label = "PWM_LED"; }; }; aliases { led0 = &led0; pwm-led0 = &pwm_led0; }; };
I think the API has been changed sometime after this video, because pwm_pin_set_usec results in a "undefined reference to `pwm_pin_set_usec'" error during compilation.
It's been 6 months I've been working with zephyrOS. And now I think why they make embedded development difficult in zephyrOS. I still struggle to use gpio for simple led toggling. Adding a node in DTS and when tried to get this node. It's not there. Device pointer is null. And still unable why it is this when i have added a node in dts, the device pointer should not be a null pointer
With your help I'll finally wrap my head around Zephyr. For buttons and leds I can highly recommend the dk_buttons_and_leds library from Nordic. Easy to use, "dynamic" number of buttons and leds and nice handling for long press events. Zephyr also has an abstraction for gpio-leds and pwm-leds with the led driver (led_on(), led_off(), led_set_brightness() which help a bit using leds.
Thanks for an excellent video!! What if I want to enable an interrupt on a pin which is not in the Device Tree. I am using a nRF52840 Dongle and wants to have sensor input on eg. gpio1 pin 13 which is not a button pin. Can I do that and can you refer me to somewhere I can see a sample?
Thanks for your great video! Related to PWM, Does Zephyr automatically selects a timer from the microcontroler to generate a PWM signal? STM32H7xx has a lot of timers, so its not clear how one and another works.
Hey Rob Good question! Generally, if you don't have a specific PWM peripheral, then you'll need to associate the timer with a PWM instance. &timers2 { status = "okay"; pwm2: pwm { status = "okay"; pinctrl-0 = ; pinctrl-names = "default"; }; }; That's an example from stm32l496g_disco.dts within the Zephyr repo. Hope that helps!
It didn't always! Things change in the course of a year+. In this case it was changed to use the dt calls back in December: github.com/zephyrproject-rtos/zephyr/commits/main/samples/basic/blinky/src/main.c
Thanks foe video, getting my head around zephyr. As you say a mental shift to understand the added abstractions but looks like it gives more flexibility in what can be done and switching boards. Great video :)
is it possible to change the default led on a raspberry pico as pwm led and assign it to any other gpio pins .
default led is at gpio 25 but the device tree for pwm_led is this :
/ {
leds {
compatible = "gpio-leds";
led0: led_0 {
gpios = ;
label = "LED";
};
};
pwm_leds {
compatible = "pwm-leds";
status = "okay";
pwm_led0: pwm_led_0 {
pwms = ;
label = "PWM_LED";
};
};
aliases {
led0 = &led0;
pwm-led0 = &pwm_led0;
};
};
I think the API has been changed sometime after this video, because pwm_pin_set_usec results in a "undefined reference to `pwm_pin_set_usec'" error during compilation.
Zephyr is a moving target. The latest documentation for PWM usage can be found here: docs.zephyrproject.org/latest/hardware/peripherals/pwm.html
It's been 6 months I've been working with zephyrOS. And now I think why they make embedded development difficult in zephyrOS.
I still struggle to use gpio for simple led toggling. Adding a node in DTS and when tried to get this node. It's not there. Device pointer is null. And still unable why it is this when i have added a node in dts, the device pointer should not be a null pointer
It's only benefit is that we don't have to write same program from start for other some other controller. I can't think of it's other possible purpose
All points well taken! It’s a ton easier now with the device_dt API compared to the past. I do feel your pain though!
Take for the very good Zephyr tutorial. A question about GPIO. How to set up a GPIO Parallel BUS.
BEST REGARDS.
Lars Sølvsten.
Hi Lars, good question! Let me see if there are any provisions in Zephyr to set up a parallel bus.
With your help I'll finally wrap my head around Zephyr. For buttons and leds I can highly recommend the dk_buttons_and_leds library from Nordic. Easy to use, "dynamic" number of buttons and leds and nice handling for long press events. Zephyr also has an abstraction for gpio-leds and pwm-leds with the led driver (led_on(), led_off(), led_set_brightness() which help a bit using leds.
Awesome thanks for the tips and for tuning in @Androbi
Could you please make a video for nRF9160 Feather to enable UART2 in existing samples application .. Ex: LWM2M_Client
I'll see what I can do!
Thanks for an excellent video!! What if I want to enable an interrupt on a pin which is not in the Device Tree. I am using a nRF52840 Dongle and wants to have sensor input on eg. gpio1 pin 13 which is not a button pin. Can I do that and can you refer me to somewhere I can see a sample?
You can create a new button like this in a device tree overlay.
/ {
buttons {
newbutton0: new_button_0 {
gpios = ;
label = "Switch 2";
};
};
};
Thanks for your great video! Related to PWM, Does Zephyr automatically selects a timer from the microcontroler to generate a PWM signal? STM32H7xx has a lot of timers, so its not clear how one and another works.
Hey Rob
Good question!
Generally, if you don't have a specific PWM peripheral, then you'll need to associate the timer with a PWM instance.
&timers2 {
status = "okay";
pwm2: pwm {
status = "okay";
pinctrl-0 = ;
pinctrl-names = "default";
};
};
That's an example from stm32l496g_disco.dts within the Zephyr repo.
Hope that helps!
Hey Rob,
I dove into your question a bit more on today's live stream. Hope that helps further. :) ua-cam.com/video/TijlHi9q4tQ/v-deo.html
the sample blinky shipped with zephyr uses "gpio_dt_spec" function instead to grab the pointer from the device tree...
It didn't always! Things change in the course of a year+. In this case it was changed to use the dt calls back in December: github.com/zephyrproject-rtos/zephyr/commits/main/samples/basic/blinky/src/main.c
Thanks foe video, getting my head around zephyr. As you say a mental shift to understand the added abstractions but looks like it gives more flexibility in what can be done and switching boards. Great video :)
Thanks Paul
Could you make a video setting up I2C on nRF9160 Feather?
Can do :)