Skip to content

Diferent behavor between website and vscode extension (rp2040 - timer) #1004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
rafaelcorsi opened this issue May 12, 2025 · 4 comments
Open
Labels
bug Something isn't working

Comments

@rafaelcorsi
Copy link

Target: Rasp Pico 1 sdk
Example project: https://wokwi.com/projects/430756341381772289

Code:

When I run it on the webpage I got the timers been canceled and created as expected, but when I run on the vs code extension, it won't create a new timer. To solve the problem I need to add a sleep between cancel and add a new timer.

        cancel_repeating_timer(&timer_b);
+       sleep_ms(10);
        add_repeating_timer_ms(300, timer_b_callback, NULL, &timer_b);
                 sleep_ms(1000);

Example code:

#include <stdio.h>
#include "pico/stdlib.h"

const int LED_PIN_R = 4;

volatile int cnt = 0;

bool timer_b_callback(repeating_timer_t* rt) {
    printf("timer %d\n", cnt++);
    return true; // keep repeating
}

int main() {
    stdio_init_all();
    gpio_init(LED_PIN_R);
    gpio_set_dir(LED_PIN_R, GPIO_OUT);

    repeating_timer_t timer_b;

    add_repeating_timer_ms(100, timer_b_callback, NULL, &timer_b);
    sleep_ms(1000);

    while (true) {
      printf("Canceled timer\n");
        cancel_repeating_timer(&timer_b);
        add_repeating_timer_ms(300, timer_b_callback, NULL, &timer_b);
                 sleep_ms(1000);

    }
}

online it creates the new timer:

Image

on vscode it get stuck

Image

@rafaelcorsi rafaelcorsi added the bug Something isn't working label May 12, 2025
@rafaelcorsi
Copy link
Author

rafaelcorsi commented May 12, 2025

Other tests:

  1. I run the uf2 generated by my build process (rasp extension) on a real hardware, and it worked
  2. I download the uf2 from wokwi web-page and run it on the vscode extension, and it worked as the web-apge, strange!

Image

@urish
Copy link
Contributor

urish commented May 25, 2025

Thanks for reporting!

This is likely to happen because of a difference in the Pi Pico SDK version.

Wokwi uses version 2.1.1: https://github.com/wokwi/wokwi-builders/blob/ce226374a33854b1c1f7ffe69b87ff04e7d5d4dc/pico-sdk/Dockerfile#L21

Which version do you have installed locally?

@rafaelcorsi
Copy link
Author

Hello @urish sorry for the delay, it works fine on the SDK 2.1.1

Is there something that I can do to fix this? Students use the first version they see on the pico extension, so I can't control this...

@urish
Copy link
Contributor

urish commented Jun 2, 2025

Which SDK version exactly does this reproduce with?

I need to be able to reproduce locally in order to be able to investigate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants