Skip to content

NANO: using floating point crashes the processor. #57

Closed
@KurtE

Description

@KurtE

We have been running into some SPI and Wire issues. So while I was testing out some SPI,
I found that I could run a simple SPI sketch which worked. I also was able to output
to a simple ST7735 display. So then wondered if maybe an issue with floating point.

So I tried a simple sketch:

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  while (!Serial && millis() < 5000) {}

}

uint32_t loop_count = 0;
uint32_t loop_increment = 63;
void loop() {
  Serial.print(loop_count);
  Serial.println();
  loop_count++;
  Serial.print(dl);

  delay(250);
}

Runs fine, now add in any floating point

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  while (!Serial && millis() < 5000) {}
}

uint32_t loop_count = 0;
uint32_t loop_increment = 63;
void loop() {
  Serial.print(loop_count);
  Serial.print(" ");
  float f = loop_count * 2.0;
  int dl = f;
  Serial.print(" ");
  Serial.print(dl);
  Serial.println();
  loop_count++;

  delay(250);
}

The board completely crashes. Any hint of floating point appears to crash.

Note: first attempt was to simply print out f like: Serial.print(f, 3);
But wanted to rule out floating point print issue...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions