I have this function that normalizes acceleration from IMU:
_Float16 normalize_accel_magnitude(_Float16 x, _Float16 y, _Float16 z, _Float16 max_g) { // Compute the magnitude squared of the acceleration vector _Float16 magnitude_squared = x * x + y * y + z * z; // Protect against very small values if (magnitude_squared < __FLT16_MIN__) { magnitude_squared = __FLT16_MIN__; } // Compute the magnitude of the acceleration vector _Float16 magnitude = sqrtf(magnitude_squared); // Normalize the magnitude using max_g if (max_g == 0.0f || fabs(max_g) < __FLT16_MIN__) { return 0.0f; } _Float16 normalized_value = (magnitude / max_g) - 1.0f; // Validate the normalized value if (!is_valid_float(normalized_value)) { return 0.0f; } return normalized_value; }
If I enable FPU
CONFIG_FPU=y
CONFIG_FPU_SHARING=y
device works for a while (10s of seconds) then reboots, if its commented out it works fine ? the issue seams to be with
sqrtf.
Any ideas why enabling FPU would cause it? Thanks!