Skip to content

[BUG] MAX31865.cpp implicit truncation results in MINTEMP error #27753

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gth-42 opened this issue Mar 21, 2025 · 2 comments
Closed

[BUG] MAX31865.cpp implicit truncation results in MINTEMP error #27753

gth-42 opened this issue Mar 21, 2025 · 2 comments

Comments

@gth-42
Copy link

gth-42 commented Mar 21, 2025

Did you test the latest bugfix-2.1.x code?

Yes, and the problem still exists.

Bug Description

Compiling MAX31865.cpp without MAX31865_USE_AUTO_MODE produces the warning:

Marlin/src/libs/MAX31865.cpp: In member function 'void MAX31865::begin(max31865_numwires_t, const_float_t, const_float_t, const_float_t)':
Marlin/src/libs/../HAL/shared/Delay.h:167:40: warning: large integer implicitly truncated to unsigned type [-Woverflow]
   #define DELAY_US(x) DELAY_CYCLES((x) * ((F_CPU) / 1000000UL))
                                    ~~~~^~~~~~~~~~~~~~~~~~~~~~~
Marlin/src/libs/MAX31865.cpp:221:5: note: in expansion of macro 'DELAY_US'
     DELAY_US(63000);
     ^~~~~~~~

and immediate MINTEMP error where applicable.
Changing line 199 of src/libs/MAX31865.cpp from DELAY_US(63000) to delay(63) resolves the compile warning and MINTEMP error. Sensing through a MAX31865 then behaves as expected.

Bug Timeline

Unknown (new user)

Expected behavior

Temperature reading through MAX31865.

Actual behavior

Compile warning and MINTEMP error

Steps to Reproduce

Configure to use a MAX31865 and desired sensor. Ensure MAX31865_USE_AUTO_MODE is not enabled. Compile and flash.

Version of Marlin Firmware

bugfix-2.1.x (Mar 20 2025 20:16:36)

Additional information & file uploads

Yes, config is wonky -- trying for minimal

x.zip

.

@thisiskeithb thisiskeithb changed the title [BUG] (MAX31865.cpp implicit truncation results in MINTEMP error) [BUG] MAX31865.cpp implicit truncation results in MINTEMP error Mar 22, 2025
@thinkyhead
Copy link
Member

thinkyhead commented May 22, 2025

I'd have to check the data sheet, but 63000 micro-seconds is 63 milliseconds, so it's probably about right for this kind of device. The warning can be eliminated by adding UL suffix to the values. Bare integers are usually native signed int type as defined for the compiler target.

enableBias();
DELAY_US(2000UL); // according to the datasheet, 10.5τ+1msec (see below)
oneShot();
DELAY_US(63000UL);

So then the question is whether this fixes the MINTEMP for you. If it does, then we can apply this patch rather than use what may be a too-small delay.

@gth-42
Copy link
Author

gth-42 commented May 23, 2025

Both delay(ms) or the UL suffix to DELAY_US works. Both fix MINTEMP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants