Multiple Devices on SPI Bus not working (TMC Steppers and Display)

Basic Information:

Printer Model: DEVELOPMENT
MCU / Printerboard: MCU = Adafruit Grand Central M4 @ 200Mhz + DEV RAMPS 2.0
klippy(9).log (798.0 KB)

Describe your issue:

I’m testing a RAMPS development board that on an Adafruit Grand Central M4 and I’m noticing a SPI Conflict with multiple different devices configured on sercom7

When TMC2130’s configured on all 5 stepper locations and a Fysetc Mini 12864 Panel (RGB) v2.1, which also runs SPI, I get the following:

Display works correctly, I can scroll though all the menus and select options correctly.
TMC2130 drivers do not initialize properly:

DUMP_TMC stepper_x
========== Write-only registers ==========
IHOLD_IRUN: 00081919 ihold=25 irun=25 iholddelay=8
MSLUT0:     aaaab554 mslut0=2863314260
MSLUT1:     4a9554aa mslut1=1251300522
MSLUT2:     24492929 mslut2=608774441
MSLUT3:     10104222 mslut3=269500962
MSLUT4:     fbffffff mslut4=4227858431
MSLUT5:     b5bb777d mslut5=3048961917
MSLUT6:     49295556 mslut6=1227445590
MSLUT7:     00404222 mslut7=4211234
MSLUTSEL:   ffff8056 w0=2 w1=1 w2=1 w3=1 x1=128 x2=255 x3=255
MSLUTSTART: 00f70000 start_sin90=247
TPWMTHRS:   000fffff tpwmthrs=1048575
COOLCONF:   00050000 sgt=5
PWMCONF:    00050480 pwm_ampl=128 pwm_grad=4 pwm_freq=1 pwm_autoscale=1
TPOWERDOWN: 00000000
========== Queried registers ==========
GCONF:      00000000
GSTAT:      00000000
IOIN:       001fff00 version=0x0
TSTEP:      00000000
XDIRECT:    00070000
MSCNT:      00000000
MSCURACT:   00000000
CHOPCONF:   00000000 mres=0(256usteps)
DRV_STATUS: 00000000 cs_actual=0(Reset?)
PWM_SCALE:  00000000
LOST_STEPS: 00000000

If I disable the entire [display] section, then the TMC drivers initialize properly.

DUMP_TMC stepper_x
========== Write-only registers ==========
IHOLD_IRUN: 00081919 ihold=25 irun=25 iholddelay=8
MSLUT0:     aaaab554 mslut0=2863314260
MSLUT1:     4a9554aa mslut1=1251300522
MSLUT2:     24492929 mslut2=608774441
MSLUT3:     10104222 mslut3=269500962
MSLUT4:     fbffffff mslut4=4227858431
MSLUT5:     b5bb777d mslut5=3048961917
MSLUT6:     49295556 mslut6=1227445590
MSLUT7:     00404222 mslut7=4211234
MSLUTSEL:   ffff8056 w0=2 w1=1 w2=1 w3=1 x1=128 x2=255 x3=255
MSLUTSTART: 00f70000 start_sin90=247
TPWMTHRS:   000fffff tpwmthrs=1048575
COOLCONF:   00050000 sgt=5
PWMCONF:    00050480 pwm_ampl=128 pwm_grad=4 pwm_freq=1 pwm_autoscale=1
TPOWERDOWN: 00000000
========== Queried registers ==========
GCONF:      00000004 en_pwm_mode=1
GSTAT:      00000001 reset=1(Reset)
IOIN:       11000078 dcin_cfg5=1 drv_enn_cfg6=1 dco=1 version=0x11
TSTEP:      000fffff tstep=1048575
XDIRECT:    00000000
MSCNT:      00000004 mscnt=4
MSCURACT:   00f70006 cur_a=6 cur_b=247
CHOPCONF:   23028384 toff=4 hend=7 tbl=1 vsense=1 mres=3(32usteps) dedge=1
DRV_STATUS: e01903ff sg_result=1023 cs_actual=25 ola=1(OpenLoad_A!) olb=1(OpenLoad_B!) stst=1
PWM_SCALE:  00000000
LOST_STEPS: 00000000

The first half of the attached klippy.log has the display enabled while the second half has the display disabled.

Both TMC2130’s and display are using SERCOM7.

Is there a way that both could be configured?

RAMPS 2.0 board is designed similar to a BTT RAMPS 1.6+ with integrated SPI from header pins to step sticks and display.

Step Sticks are all BTT TMC2130 v3.0

Adafruit GC M4 is main MCU - https://learn.adafruit.com/adafruit-grand-central?view=all#downloads
Grand Central M4 Pinout: Adafruit-Grand-Central-PCB/Adafruit Grand Central M4 Express Pinout.pdf at master · adafruit/Adafruit-Grand-Central-PCB · GitHub

I think your instantiation of your SPI is faulty.

You may have a look here Serial Peripheral Interface – Wikipedia have a look, what the “cs pins” are for…

…and especially here Configuration reference - Klipper documentation search for your TMC2130!

Good luck, hcet14

@hcet14 Thanks for the input. I already referenced the Klipper docs. The samd chipset is a bit odd when it comes to configuring the SPI and i2c bus.

For reference, here is the display schematic: FYSETC-Mini-12864-Panel/hardware/V2.1/Mini12864(RGB)V2.1_sch.pdf at master · FYSETC/FYSETC-Mini-12864-Panel · GitHub

The Display requires:
LCD_CS, LCD_RST, LCD_A0, spi SCK and spi MOSI.

NOT being used: MISO, SS (CS pin for SD card), and CD (SD detect) as they are wired to the SD slot which is not supported or used.

TMC2130’s need:
MISO, MOSI, SCK and each has a unique CS pin

It is also possible that there is so much display data going over the shared SPI bus that the TMC communications is lost?

I know @koconnor has experience with Adafruit Metro M4, maybe he has more insight on the samd_sercom setings?

@jjarosz

Please don’t

That guy has enough to manage!

We may figure that out with the help of the community.

Can we do that in the future (means tomorrow)? I’m fu…ing tired. Sorry.

Sorry for yesterday, I slept very well. Can you post a picture of your Adafruit Grand Central M4 connected to your (I guess) 7 TMC2130s?

How did you implemented the connection from this Adafruit Learning System to 7 of those BIGTREETECH-Stepper-Motor-Driver/TMC2130/V3.0/Hardware/1 2130.jpg at master · bigtreetech/BIGTREETECH-Stepper-Motor-Driver · GitHub?

I’m very, very curious how you did that! Where comes your VS (see https://www.trinamic.com/fileadmin/assets/Products/ICs_Documents/TMC2130_datasheet_rev1.16.pdf) for the TMC2130s from?
I’m excited!

@hcet14
Reminder, this is a prototype board, effectively a new RAMPS design that will support a MEGA, Re-ARM, Due, and Grand Central M4.

I’m not the board designer, but I’ve provided input, inspiration, now testing, and documentation.

This specific design has multiple voltage rails:
Vcc - to support 3v3 and 5v logic
5v rail for fans and other accessories
12v rail for fans and accessories (npn/pnp sensors)
24v rail for steppers
8v-ish rail to power the MCU

This is what it looks like in a custom box I’ve created.

Here is the schematic:
RAMPS_2.0-P1-9(rev.A-E) 2.pdf (945.4 KB)
Page 7 has display pins
Page 9 has stepper pins

Just like the BTT Ramps 1.6+, the SPI is baked into the board between the display and the 5 stepper locations.

Each stepper has its own Cs pin.
The display has a unique Cs for the display and the SPI SS is unused, however connected to the SD on the display.

Currently, I have working either the display OR TMC2130 over hardware SPI on the Adafruit Grand Central. SPI is configured using the [samd_sercom] section.
I can, with some jumpers wires, put the display on unused pins and configure software SPI, but that is not how I ultimately want to set up as I’m testing what can/cannot be done.

I recently configured [static_digital_output disable_sdcard] to disable the SPI SS pin. Haven’t tested it yet.

Let me know your thoughts.

1 Like

:ok_hand: very,very cool. I was expecting something else.

So you have 5 steppers at the start, not 7?

There is just one stepper, where are the others?
How did you connect RAMPS 2.0 to your Adafruit Grand Central M4?

I have an idea, but again tired and I want to play with the idea and sleep it over. I come back to you by tomorrow.

But again :ok_hand:

The Adafruit GC is under the RAMPS board.

The RAMPS board has 5 steppers, all TMC2130’s

I have a second MCU_Z, which is an Adafruit Metro M4. This board has 4 additional steppers. This board has a custom 4-stepper board similar to a UNO CNC Shield.

This gives me a total of 9 steppers.

Schematics? How are the boards connected?

Holy cow, what are you doing with 9 steppers?

They are sandwiched just like this RAMPs 1.6 and Arduino Mega:

My printer is similar to a VORON; core XY

2 for XY
4 for Z
3 for non-mixing extruders

In the first image above, I have 5 step-sticks installed, but only one stepper motor plugged in. I only have a couple extra steppers not being used at the moment.

Got it. Hasta mañana.

1 Like

I guess the bad boy is the cs_pin = exp1_3 of your display. The pin is probably always activated and blocks the SPI for other devices.
You may follow this TMC drivers - Klipper documentation instructions. Go to “I keep getting “Unable to write tmc spi ‘stepper_x’ register …” errors?”
You just have to try, if high or low level works Configuration reference - Klipper documentation.
I’ll keep my fingers crossed.

Nope, still not working.

I’ll try to turn off hardware SPI and use the same pins as Software SPI for both Display and TMC to see what happens. That might show there is something wrong in the samd_sercom Klipper code.

No dice on using same pins as software SPI either.

Will have to wait to see if someone else has some suggestions.

I cannot contribute to a solution but:

If no “simple” solution is available, then it looks like you are heading for some tedious debugging with Logic Analyzer etc. to see where things start going downhill.

@Sineos
Thanks for supplying the GitHub ticket. It actually contains the work I did to convert a RAMPS 1.6 for the GC, unfortunately I only used the DRV8825 steppers. The only SPI device was the MKS mini display.

Nonetheless it was a good thing for me to review.

We are looking into a couple ideas for the next iteration of the board as we continue to see if there is a limitation/issue to the GC SPI bus or even something possibly an issue with the Klipper samd_sercom implementation?

Bummer. Can you post your klippy.log from that try?

This one should be it.
klippy(11).zip (2.8 MB)

I also made a custom cable from the MCU shield to the display for EXP2, only taking the 2 click pins and MOSI and SCK. The display does not need MISO. EXP1 has the LCD CS and LCD A0.

No luck with these two either high or low:

[static_digital_output disable_sdcard]
pins = !PC5,!PD10

Something of interest with how to configure the samd chip for for the sercom:

samd_sercom is configured as such:

[samd_sercom gc_sercom7]
sercom: sercom7
tx_pin: mcu:aux3_mosi
rx_pin: mcu:aux3_miso
clk_pin: mcu:aux3_sck

These pins are specific for this sercom# on the board. Not sure if the sercom: value makes any difference?

For the TMC drivers and the display, I configured:


[tmc2130 stepper_x]
cs_pin: x_cs
spi_bus: sercom7
interpolate: False
run_current: 0.80 #Don't go below 0.75
stealthchop_threshold: 0
driver_SGT: 5
diag1_pin: ^!x_idx

You cannot specify the MCU or use any portion of [samd_sercom gc_sercom7] as the spi_bus value.

What if someone want’s to use multiple Adafruit Metro M4 or Grand Central M4? Would there be a conflict in sercom#?

Is your syntax right? Shouldn’t it be

[static_digital_output disable_sdcard]
pins: !PC5,!PD10

according to Configuration reference - Klipper documentation