Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8042

Other RP2040 boards • problem light led ws2812 on rp2350 zero

$
0
0
Hello.
I managed to get the Pio WS2812 example working on an RP2350 Zero. The LED colors light up correctly.

Now I wanted to adapt the example from https://tutoduino.fr/pio-rp2040/ because the Pio program seems simpler, but the main program is in MicroPython.

I adapted it for the C SDK, but I can't get the WS2812 LED to light up.

I must have made a mistake, but I can't find it.

Here is the Pio code:

Code:

.program ws2812.wrap_target    out x, 1      ;  1 step is 0.2us (clock frequency must be set to 5MHz)    set pins 1 [1] ;    mov pins x [1]    set pins 0 .wrap% c-sdk {#include "hardware/clocks.h"static inline void ws2812_program_init(PIO pio, uint sm, uint offset, uint pin, float freq, bool rgbw) {    pio_gpio_init(pio, pin);    gpio_put(pin,0);    pio_sm_set_consecutive_pindirs(pio, sm, pin, 1, true);    pio_sm_config c = ws2812_program_get_default_config(offset);    //sm_config_set_sideset_pins(&c, pin);    sm_config_set_out_shift(&c, false, true, 24);    //sm_config_set_fifo_join(&c, PIO_FIFO_JOIN_TX);    //int cycles_per_bit = ws2812_T1 + ws2812_T2 + ws2812_T3;    float div = clock_get_hz(clk_sys) / (freq );    sm_config_set_clkdiv(&c, div);    pio_sm_init(pio, sm, offset, &c);    pio_sm_set_enabled(pio, sm, true);}%}
and parts on C program :

Code:

 bool success = pio_claim_free_sm_and_add_program_for_gpio_range(&ws2812_program, &pio, &sm, &offset, WS2812_PIN, 1, true); hard_assert(success); ws2812_program_init(pio, sm, offset, WS2812_PIN, 5000000.0, IS_RGBW); printf("Blinking pin %d sm %d pio %p \n", WS2812_PIN, sm,pio);  int t = 0; int couleur = urgb_u32(0x77, 0x77, 0x77); put_pixel(pio, sm, couleur);  sleep_ms(500);  couleur=urgb_u32(0xff, 0, 0); put_pixel(pio, sm, couleur); sleep_ms(500);
Thanck.

Statistics: Posted by VincentARM — Mon Dec 22, 2025 2:44 pm



Viewing all articles
Browse latest Browse all 8042

Trending Articles