KrisKasprzak
Well-known member
All,
I have a datalogger project based on a Teensy 3.2 that uses a database library to save telemetry data to a flash chip. Over they last 3 years, I've logged > 100 MB of data and have never lost a single bit. The driver can save a wide variety of data types.
I've converted my project to a Teensy 4.0 and using the same code. I'm noticing conversion for floats using memcpy() fails occasionally--as in every few seconds. Heck even bit shifting to convert a uint16_t to 2 bytes can fail every few minutes. In either case, one of the converted bytes is 255--this never happens if compiled on a 3.2
Below is a snipped of my code, which may get called 20 times a second.
compiling to run at 600 mhz--although different speeds makes no difference
compiling to smallest code--although other settings e.g. fastest makes no difference
using Arduino 2.1.0
using Teensduino 1.58
Any thoughts?
I have a datalogger project based on a Teensy 3.2 that uses a database library to save telemetry data to a flash chip. Over they last 3 years, I've logged > 100 MB of data and have never lost a single bit. The driver can save a wide variety of data types.
I've converted my project to a Teensy 4.0 and using the same code. I'm noticing conversion for floats using memcpy() fails occasionally--as in every few seconds. Heck even bit shifting to convert a uint16_t to 2 bytes can fail every few minutes. In either case, one of the converted bytes is 255--this never happens if compiled on a 3.2
Below is a snipped of my code, which may get called 20 times a second.
compiling to run at 600 mhz--although different speeds makes no difference
compiling to smallest code--although other settings e.g. fastest makes no difference
using Arduino 2.1.0
using Teensduino 1.58
Any thoughts?
Code:
// aBytes[8] is a private uint8_t variable
// fdata[i] is a pointer to passed-in data (and is 100% reliable)
memcpy(aBytes, (void *)fdata[i], 4);
if ( (aBytes[0] == 255) || (aBytes[1] == 255) || (aBytes[2] == 255) || (aBytes[3] == 255) ){
Serial.println("float convert failed");
Serial.print(*fdata[i]);
Serial.print(": ");
Serial.print(aBytes[0]);
Serial.print("-");
Serial.print(aBytes[1]);
Serial.print("-");
Serial.print(aBytes[2]);
Serial.print("-");
Serial.println(aBytes[3]);
}
// results
float convert failed
0.00: 6-140-255-58
float convert failed
0.01: 251-226-255-59
float convert failed
79.62: 255-59-159-66