Kitchen timer based on 4-digit 8-segment display 3461BS and RP Pico
| Front view of the PCB |
| Back view of the PCB |
The used display is a common anode display. The datasheet specifies 10 mA typical current for the optical characteristics of a segment. The GPIOs of RP Pico can provide 12 mA max. The built-in 3V3OUT voltage regulator can output up to 300 mA, which is sufficient for all 8 segemts. Not the full 32 segments are needed since the digits are displayed with a given refresh rate sequentially once at a time. Simulation using LTSpice and PNP transistor BCS327-25 leads to the choice of resistor value
s with 220 Ohm and 22k. For the edge cases "1 segment" and "8 segments" the current limitations are fulfilled.
-
Start by enabling PWM in the
prj.conffile:CONFIG_PWM=y -
In the
.overlayfile, enable the nodepwm_led0by setting the status:&pwm_led0 { status = "okay"; };
-
Check the PWM generator corresponding to the GPIO. For RP Pico, these are:
It results in a table:
PWM channel Nr. PWM channel GPIO 0 0A 0 1 0B 1 2 1A 2 .. .. .. 15 7B 15 0 ❗ 0A 16 1 0B 17 This means that to set PWM ON GPIO 27, we will need
PWM 5Bwith the number11. -
In the
.dtsfile (not the overlay!), edit thepwm_ledsnode:pwm_leds { compatible = "pwm-leds"; status = "disabled"; pwm_led0: pwm_led_0 { pwms = <&pwm 11 PWM_MSEC(20) PWM_POLARITY_NORMAL>; label = "PWM_LED"; }; };
-
Next, set the PWM on the specific pin. In the
rpi_pico-common.dtsi:&pwm { pinctrl-0 = <&pwm_ch5b_default>; pinctrl-names = "default"; };
-
Finally, add the pinmux in
rpi_pico-pinctrl.dtsifor GPIO 27:pwm_ch5b_default: pwm_ch5b_default { group1 { pinmux = <PWM_5B_P27>; }; };
-
Follow the examples such as PWM Blinky and compile them with the changed devicetree. If it works, start coding your own application.
Device tree nodes are aliased like in the picture below. The change from - to _ is mandatory!
In the .c code, the alias is used like:
static const struct pwm_dt_spec my_variable = PWM_DT_SPEC_GET(DT_ALIAS(buzzer_dev));