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

General • Pico 2W (RP2350) Turn on a led without SDK

$
0
0
Hello,
I'm trying to turn on a led without using SDK function.
Basically I'm trying to replicate this code:

Code:

    const uint32_t LED_PIN = 0;    gpio_init(LED_PIN);    gpio_set_dir(LED_PIN, GPIO_OUT);    gpio_put(LED_PIN, 1);    while (true);
Based on the informations I've read I've written:

Code:

#define GPIO_BASE 0x40014000#define SIO_BASE 0xD0000000#define GPIO_CTRL_OFFSET 0x04#define GPIO_OE_SET_OFFSET 0x24#define GPIO_OUT_SET_OFFSET 0x14#define LED_PIN 0 // Using GPIO 0 (GP0)#define REG32(addr) (*(volatile uint32_t *)(addr))int main(void) {    REG32(GPIO_BASE + (LED_PIN * 8) + GPIO_CTRL_OFFSET) = 0x05;    REG32(SIO_BASE + GPIO_OE_SET_OFFSET) = (1 << LED_PIN);    REG32(SIO_BASE + GPIO_OUT_SET_OFFSET) = (1 << LED_PIN);    while (1) {        __asm__("nop");    }    return 0;}
But it is not working (led is always off).

I am wondering: maybe the addresses I'm using aren't correct? Or maybe the RP2350 is using a GPIO coprocessor, so its initialization is required?

Thanks a lot and sorry for the newbie question!

Statistics: Posted by Luca91 — Sat Jan 25, 2025 5:28 pm — Replies 4 — Views 114



Viewing all articles
Browse latest Browse all 4630

Trending Articles