• Re: Baremetal programiing the Pimoroni Tiny2040 RGB LED

    From Single Stage to Orbit@alex.buell@munted.eu to comp.sys.raspberry-pi on Sat Jan 17 15:21:51 2026
    From Newsgroup: comp.sys.raspberry-pi

    On Mon, 2026-01-12 at 10:57 +0000, Gordon Henderson wrote:
    like to know how to do it baremetal with ARM thumb assembly.

    ... my use is the RISC-V cores in the rp2350, so bare metal RISC-V asembly.... But the principle for programming the PWM generators
    is more or less the same from eith CPU, so I understand, but it's
    something I've not gotten round to.

    I'd suggest to have a look at the manual and SDK and see how to do it
    from C then hand translate the C code into ASM...
    I've found the following: https://github.com/thejpster/rp-hal-rp2350-public/blob/main/rp235x-hal/examples/pwm_blink.rs
    Looks like this is what I've been looking for.
    The funny thing is that the Pimoroni tiny2040 that I also have has a
    RGB LED on it, there's no data sheet for it but it appears to be
    reversed, in that all the GPIO pins attached to this LED are all active
    low, (i.e ~R GPIO18, ~B GPIO19, ~G GPIO20) so works in the opposite way
    to the LED on GPIO 25 on rp2040!
    --
    Tactical Nuclear Kittens
    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From Single Stage to Orbit@alex.buell@munted.eu to comp.sys.raspberry-pi on Sat Jan 17 15:04:30 2026
    From Newsgroup: comp.sys.raspberry-pi

    On Sun, 2026-01-11 at 18:52 +0000, Daniel James wrote:

    However: There is a section on hardware PWM in the Pico-series C/C++
    SDK, have you seen that?
    Oh interesting, I can take a look at that. Hopefully the sources will
    clarify what's required.
    I confess it's not something I've played with, but it doesn't look
    too impenetrable ... it doesn't require PIO programming (something
    else I haven't played with yet) like another example I found.
    No, you're right, thankfully I don't need to go down that PIO rabbit
    hole yet. Just to demysterify how to do the PWM in assembly.
    I'm not sure how long ago I downloaded this SDK so it may not be
    quite current ... but it's section 4.1.18 on P249.

    If you used a capable search engine you might stumble across this:

    https://forums.raspberrypi.com/viewtopic.php?t=344634

    which seems to shed some light ...
    Thanks.
    --
    Tactical Nuclear Kittens
    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From Single Stage to Orbit@alex.buell@munted.eu to comp.sys.raspberry-pi on Sat Jan 17 15:07:21 2026
    From Newsgroup: comp.sys.raspberry-pi

    On Sun, 2026-01-11 at 19:36 +0000, The Natural Philosopher wrote:
    From: https://www.raspberrypi.com/documentation/pico-sdk/hardware.html#group_hardware_pwm
    Excellent, I missed that one.
    Thanks,
    Alex
    --
    Tactical Nuclear Kittens
    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From Michael Schwingen@news-1513678000@discworld.dascon.de to comp.sys.raspberry-pi on Sun Jan 18 10:32:40 2026
    From Newsgroup: comp.sys.raspberry-pi

    On 2026-01-17, Single Stage to Orbit <alex.buell@munted.eu> wrote:
    I'd suggest to have a look at the manual and SDK and see how to do it
    from C then hand translate the C code into ASM...

    I've found the following:

    https://github.com/thejpster/rp-hal-rp2350-public/blob/main/rp235x-hal/examples/pwm_blink.rs

    Why not go to the primary source?

    I believe the RP2xx0 datasheet has all you need in the PWM chapter (CH 4.5
    for RP2040, or CH 12.5 for RP2350).

    There is a list of registers with all the relevant bits explained.

    The funny thing is that the Pimoroni tiny2040 that I also have has a
    RGB LED on it, there's no data sheet for it but it appears to be
    reversed, in that all the GPIO pins attached to this LED are all active
    low, (i.e ~R GPIO18, ~B GPIO19, ~G GPIO20) so works in the opposite way
    to the LED on GPIO 25 on rp2040!

    This is quite common - they probably used a 4-pin LED package with common anode, so you have to drive the individual lines low to activate the LED.
    You could use 3 external inverters or transistors to make them active high,
    but why bother (the parts cost money and take up PCB space) when all it
    takes to fix this is a single line of code on the software side?

    cu
    Michael
    --
    Some people have no respect of age unless it is bottled.
    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From Daniel James@daniel@me.invalid to comp.sys.raspberry-pi on Sun Jan 18 12:37:31 2026
    From Newsgroup: comp.sys.raspberry-pi

    On 17/01/2026 15:21, Single Stage to Orbit wrote:
    The funny thing is that the Pimoroni tiny2040 that I also have has a
    RGB LED on it, there's no data sheet for it but it appears to be
    reversed, in that all the GPIO pins attached to this LED are all active
    low, (i.e ~R GPIO18, ~B GPIO19, ~G GPIO20) so works in the opposite way
    to the LED on GPIO 25 on rp2040!

    Did you read Pimoroni's own website entry for that part?

    https://shop.pimoroni.com/products/tiny-2040

    where it says:

    *Notes*

    * The RGB LED is connected to GP18-GP20 and active low (so the
    on/off state will work in the opposite way to the LED on a
    Raspberry Pi Pico). You can PWM the pins to dim the LED - check
    out Tonygo2's MicroPython example.

    The example cited is Python, so not directly of use to you, but here is
    the link, anyway:

    https://forums.pimoroni.com/t/tiny-2040-rgb-led-control-tutorial/16604
    --
    Cheers,
    Daniel.
    --- Synchronet 3.21b-Linux NewsLink 1.2