Closed
Description
I just spent a few hours trying to figure out what was wrong with my code as it was behaving very strangely (a for loop wouldn't increment) altough it was working just fine with the oficial core as well as with other microcontrollers.
I found I had defined a value returning function with several ifs and returns but the part the code was following didn't actually have a return in the end and therefore the pico was crashing. Here is a very simple example that replicates the issue in case my explanation isn't clear enough. Notice how printTest( ) doesn't return anything but is defined as an int returning function. I can see how a lot of people could get stuck with this issue as it isn't really easy to debug if the code is large.
int i;
void setup() {
Serial.begin(115200);
}
void loop() {
printTest();
delay(500);
}
int printTest(){
Serial.println(i);
i++;
}
Metadata
Metadata
Assignees
Labels
No labels