Marlin icon indicating copy to clipboard operation
Marlin copied to clipboard

STM32 HAL software SPI bug revisited

Open AapoTahkola opened this issue 2 years ago • 1 comments

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

Yes, and the problem still exists.

Bug Description

Board is Fysetc spider v2.2 with MAX6675 connected to M8. https://wiki.fysetc.com/PT100_STICK/ is similar to how one would connect MAX6675 or MAX31855. It is the same module with big terminals that comes up with web search. I added

SERIAL_ECHOLNPGM("tc ", max_tc_temp);

to read_max_tc function and turned _temp_error into a no-op so I could debug little easier. Anyway, with the thermocouple disconnected I get values 32764 or 16382 in a random pattern

(gdb) print /t 32764
$1 = 111111111111100
(gdb) print /t 16382
$2 = 11111111111110
(gdb) 

MAX6675 datasheet states

it D2 is normally low and
goes high when the thermocouple input is open.

At room temperature I get values like

Recv: tc 920
Recv: tc 452

So it seems that the software SPI just shifts one bit at random.

Bug Timeline

No response

Expected behavior

No response

Actual behavior

No response

Steps to Reproduce

No response

Version of Marlin Firmware

Marlin bugfix-2.1.x

Printer model

Fysetc spider v2.2

Electronics

No response

Add-ons

max6675

Bed Leveling

ABL 3-point

Your Slicer

No response

Host Software

OctoPrint

Don't forget to include

  • [X] A ZIP file containing your Configuration.h and Configuration_adv.h.

Additional information & file uploads

bug_report.zip

AapoTahkola avatar Jul 25 '22 09:07 AapoTahkola

Tried a bunch of things at HAL/STM32/HAL_SPI.cpp SOFTWARE_SPI with no improvement and then just implemented MAX_SUPERSAMPLES with a value of 5 which just reads the thermocouple multiple times and tests shift error against highest of the 5, finally returning the average value. Checked against multimeter thermocouple and it is spot on and super smooth.

AapoTahkola avatar Jul 25 '22 16:07 AapoTahkola

This issue has had no activity in the last 60 days. Please add a reply if you want to keep this issue active, otherwise it will be automatically closed within 10 days.

github-actions[bot] avatar Sep 24 '22 02:09 github-actions[bot]

I have not been able to acquire MAX31855 for testing. Random "nop;"'s at softspi.h:receiveBit did not help.

AapoTahkola avatar Sep 26 '22 16:09 AapoTahkola

This issue has had no activity in the last 60 days. Please add a reply if you want to keep this issue active, otherwise it will be automatically closed within 10 days.

github-actions[bot] avatar Nov 27 '22 02:11 github-actions[bot]

Also occurs on max31855. I could check the timing with a logic analyzer however...

AapoTahkola avatar Nov 30 '22 23:11 AapoTahkola

closing

AapoTahkola avatar Jan 30 '23 22:01 AapoTahkola

This issue has had no activity in the last 60 days. Please add a reply if you want to keep this issue active, otherwise it will be automatically closed within 10 days.

github-actions[bot] avatar Apr 01 '23 01:04 github-actions[bot]

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Jun 10 '23 14:06 github-actions[bot]