Why did my while(1) not halt the device?

argon
Tags: #<Tag:0x00007f1ca2d29dd8>

#1

Hi guys, new particle developer here :slight_smile:

Sorry for what I know is going to be an absolutely noob question… but…

I put a while(1); loop in my firmware (using VS Code and flashing via serial USB). It did halt the execution of my code, but the DeviceOS still ran. What’s going on there then?

Cheers!!

Dan


#2

What do you mean with device OS still running?
How does your code look?


#3

As in the LED on the Argon kept breathing, which means my while(1) didn’t lock the system up. My code is as follows:

void loop() {
  pressureSensor pressureSensor_c;  //_c for class recognition

  float mVolts = pressureSensor_c.getVoltage()*1000;
  Serial.print("ADC Voltage = ");
  Serial.print(mVolts, 3); // second arg for force precision
  Serial.println("mV");

  String voltage_str = String(mVolts, 3);
  Serial.println(voltage_str);
  while(1);    //this while(1) doesn't halt the device, as the RGB LED kept breathing
}

#4

Your while(1); cannot intercept interrupts and FreeRTOS will also run threads that are independent of the application thread.


#5

Thanks ScruffR. Is there a way that I can monitor resources easily? Number of threads running etc?