gpio_set_irq_enabled_with_callback on the PiPico lazarus / 68-Other OS ---------------------------------------------------------------------- Germo · 2025-06-15 09:25 I'm enjoying FreePascal for programming my PiPico, but i ran into trouble. I managed to use the GPIO. But i can't get the IRQ on that working. When i start my program on the PiPico, the debugger halts on the 'gpio_set_irq_enabled_with_callback' function. Anyone can point me in the right direction? ---------------------------------------------------------------------- Thaddy · 2025-06-15 14:13 You need to do this something like this:Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program gpio_irq_test; {$MODE OBJFPC}{$H+} uses  pico_gpio_c, pico_irq_c; const  LED_PIN = 25;  IRQ_PIN = 15; procedure irq_callback(gpio: byte; events: longword); cdecl;begin  gpio_put(LED_PIN, not gpio_get(LED_PIN)); // Toggle LED on IRQend; begin  stdio_init_all;  gpio_init(LED_PIN);  gpio_set_dir(LED_PIN, GPIO_OUT);  gpio_init(IRQ_PIN);  gpio_set_dir(IRQ_PIN, GPIO_IN);  gpio_pull_up(IRQ_PIN);   gpio_set_irq_enabled_with_callback(    IRQ_PIN,    GPIO_IRQ_EDGE_FALL,    true,    @irq_callback  );   while true do    // Main loop  end;end. And make sure you do this: Link with pico_multicore, pico_stdlib, and hardware_gpio. But you did not give me the hardware you want to control. So your milage may vary. The above is very simple - for IoT fanatics like you and me, and should work. Note everything is cdecl, but you know that. ---------------------------------------------------------------------- Germo · 2025-06-15 16:11 Quote from: Thaddy on June 15, 2025, 04:13:50 pm But you did not give me the hardware you want to control. So your milage may vary. The above is very simple - for IoT fanatics like you and me, and should work. Note everything is cdecl, but you know that. Thanks for the reply, but that does not work for me. I'm using a rp2040. (after https://wiki.freepascal.org/ARM_Embedded_Tutorial_- _FPC_and_the_Raspberry_Pi_Pico ) I thought it would be very simple, but adding the irq-handler seems to not work And no, i did not know that everything is cdecl (but that did not do the trick) ---------------------------------------------------------------------- Thaddy · 2025-06-15 17:35 Come back later, this was just a part of my robot code. It should have helped you , though. You are probably over-complicating things. Can you give some code that is not working? My example was targeted at the 2040. The key is the callback.