Unable to write tmc spi register on Duet3HC

Hello. I’m trying to run Klipper on a Duet3 3HC and a Duet3 6HC. I have a problem when configuring the stepper motor drivers tmc5160 on the Duet3HC with SPI. The following error is displayed: “Unable to write tmc spi ‘stepper_z’ register GLOBALSCALER”. I have checked that all pins are specified correctly and tried to find a solution on the forum. I haven’t checked if the drivers work with the original RepRap Firmware yet, maybe the problem is in the board. Perhaps this functionality is not written for MCU SAME51N19 in Klipper code. Maybe the problem is connected with SPI connection via CAN, or there is a mistake with the printer.cfg file. If you have any ideas, please advise. Here are the settings from printer.cfg:

[stepper_z]
#driver0
step_pin: duet3hc:PA25
dir_pin: duet3hc:PA23 
enable_pin: !duet3hc:PB23
microsteps: 16
rotation_distance: 32
homing_speed: 16
endstop_pin: duet3hc:PA6 #tmc5160_stepper_z:virtual_endstop
homing_retract_dist: 0
position_endstop: 0
position_max: 420
homing_positive_dir: false

[tmc5160 stepper_z]
cs_pin: duet3hc:PB22
# spi_bus: spi0
spi_software_mosi_pin: duet3hc:PB24
spi_software_miso_pin: duet3hc:PC25
spi_software_sclk_pin: duet3hc:PB25
chain_position: 1
chain_length: 3
interpolate: True
run_current: 1.1                                  
sense_resistor: 0.05                              
stealthchop_threshold: 63
diag0_pin: ^!duet3hc:PA9
driver_SGT: -64

Please read this to know about the importance of the template:

Thanks for the comment. Here’s the information:

Basic Information:

Printer Model: self-made
MCU / Printerboard: Duet3 6HC + Duet 3 Expansion 3HC
Host / SBC: Raspberry Pi 4
klippy.log (253.2 KB)

I don’t know if this is per board, but mine worked only when I specified diag pin as “diag1_pin” pin

I’ve checked that drivers work with the original RepRap Firmware. I think the problem is not in the printer.cfg, but most likely in the source code. I couldn’t debug this situation with openOCD and SWD, because I don’t know how to send gcode that causes an error (web interface is unavailable during debugging).

found a solution, I had to set spi pins via samd_sercom. Now everything works, thanks.

[tmc5160 stepper_z]
cs_pin: duet3hc:PB22
spi_bus: sercom0
chain_position: 1
chain_length: 3
interpolate: True
run_current: 1.1                                 
sense_resistor: 0.05                            
stealthchop_threshold: 63
diag0_pin: ^!duet3hc:PA9
driver_SGT: -64

[samd_sercom sercom0]
sercom: sercom0
tx_pin: duet3hc:PB24
rx_pin: duet3hc:PC25
clk_pin: duet3hc:PB25