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

General • Different behavior between run/flash/debug (newbie)

$
0
0
I'm just getting started with the RP2040 so I might be overlooking something really basic here.

I'm in Linux using VS Code with the official plugin and SDK 2.1.

I have a really basic program that I just want to see use both cores. Core0 just writes a counter to serial, and core1 increments the counter. When I run this in debug, or I use the "Run Project (USB)" button it works as expected. However, if I use the "Flash Project (SWD)" option, core1 seems to increment once and then stop.

What might explain why the behavior is different?

Code:

#include <stdio.h>#include "pico/stdlib.h"#include "pico/multicore.h"int x = 0;/// Entry point for core1void main1(){    while (true) {        x += 5; // yes, I understand that this is not thread-safe        sleep_ms(500);    }}int main(){    stdio_init_all();    multicore_launch_core1(main1);    while (true) {        printf("Hello, world! %d\n", x);        sleep_ms(1000);    }}
run/debug output:

Code:

Hello World! 5Hello World! 15Hello World! 25
flash output:

Code:

Hello World! 5Hello World! 5Hello World! 5

Statistics: Posted by aaronmj — Tue Dec 31, 2024 8:29 pm — Replies 0 — Views 20



Viewing all articles
Browse latest Browse all 4436

Trending Articles