Klipper3d / klipper

Klipper is a 3d-printer firmware
GNU General Public License v3.0
9.4k stars 5.3k forks source link

SKR E3 DIP with TMC5160 (pin PB15 is reserved for spi2) #2072

Closed r15ch13 closed 4 years ago

r15ch13 commented 5 years ago

I was trying to use the SKR E3 DIP with TMC5160 drivers. I copied the generic-bigtreetech-skr-mini-e3.cfg and changed the PINs according to the sheet from BIGTREETECH and also referencing the pins_BIGTREE_SKR_E3_DIP.h from Marlin 2.x.

But after running sudo service klipper restart it shows the following error: pin PB15 is reserved for spi2

I then changed it to another PIN (for testing) and got the same error for PB14 and PB13. According to https://www.klipper3d.org/stm32f1.html these PINs are used for SPI or as general I/O.

Digging around the source revealed: https://github.com/KevinOConnor/klipper/blob/1e8582e3f6cb13d85f06c740d7f79824c15a88be/src/stm32/spi.c#L17-L18 Is it possible to disable spi2?

klippy.log

r15ch13 commented 5 years ago

Setting spi_bus to spi1 seems to work.

[tmc5160 stepper_x]
cs_pin = PC10
spi_bus = spi1

Running STEPPER_BUZZ STEPPER=stepper_x does nothing though...

klippy.log

Send: DUMP_TMC stepper=stepper_x
Recv: // ========== Write-only registers ==========
Recv: // TPWMTHRS:   0000005e TPWMTHRS=94
Recv: // COOLCONF:   00000000
Recv: // IHOLD_IRUN: 00060504 IHOLD=4 IRUN=5 IHOLDDELAY=6
Recv: // TPOWERDOWN: 0000000a TPOWERDOWN=10
Recv: // ========== Queried registers ==========
Recv: // GCONF:      ffffffff recalibrate=1 faststandstill=1 en_pwm_mode=1 multistep_filt=1 shaft=1(Reverse) diag0_error=1 diag0_otpw=1 diag0_stall=1 diag1_stall=1 diag1_index=1 diag1_onstate=1 diag1_steps_skipped=1 diag0_int_pushpull=1 diag1_poscomp_pushpull=1 small_hysteresis=1 stop_enable=1 direct_mode=1 test_mode=1
Recv: // CHOPCONF:   ffffffff toff=15 hstrt=7 hend=15 fd3=1 disfdcc=1 chm=1 tbl=3 vhighfs=1 vhighchm=1 tpfd=15 MRES=15(0usteps) intpol=1 dedge=1 diss2g=1 diss2vs=1
Recv: // GSTAT:      ffffffff reset=1(reset) drv_err=1(ErrorShutdown!) uv_cp=1(Undervoltage!)
Recv: // DRV_STATUS: ffffffff SG_RESULT=1023 s2vsa=1 s2vsb=1 stealth=1 fsactive=1 CSACTUAL=255 stallGuard=1 ot=1(OvertempError!) otpw=1(OvertempWarning!) s2ga=1(ShortToGND_A!) s2gb=1(ShortToGND_B!) ola=1(OpenLoad_A!) olb=1(OpenLoad_B!) stst=1
Recv: // FACTORY_CONF: ffffffff FACTORY_CONF=31
Recv: // IOIN:       ffffffff REFL_STEP=1 REFR_DIR=1 ENCB_DCEN_CFG4=1 ENCA_DCIN_CFG5=1 DRV_ENN=1 ENC_N_DCO_CFG6=1 SD_MODE=1 SWCOMP_IN=1 VERSION=0xff
Recv: // LOST_STEPS: ffffffff LOST_STEPS=1048575
Recv: // MSCNT:      ffffffff MSCNT=1023
Recv: // MSCURACT:   ffffffff CUR_A=-1 CUR_B=-1
Recv: // OTP_READ:   ffffffff OTP_FCLKTRIM=31 otp_S2_LEVEL=1 otp_BBM=1 otp_TBL=1
Recv: // PWMCONF:    ffffffff PWM_OFS=255 PWM_GRAD=255 pwm_freq=3 pwm_autoscale=1 pwm_autograd=1 freewheel=3 PWM_REG=15 PWM_LIM=15
Recv: // PWM_SCALE:  ffffffff PWM_SCALE_SUM=255 PWM_SCALE_AUTO=-1
Recv: // PWM_AUTO:   ffffffff PWM_OFS_AUTO=255 PWM_GRAD_AUTO=255
Recv: // TSTEP:      ffffffff TSTEP=1048575
Recv: ok

Send: DUMP_TMC stepper=stepper_y
Recv: // ========== Write-only registers ==========
Recv: // TPWMTHRS:   0000005e TPWMTHRS=94
Recv: // COOLCONF:   00000000
Recv: // IHOLD_IRUN: 00060504 IHOLD=4 IRUN=5 IHOLDDELAY=6
Recv: // TPOWERDOWN: 0000000a TPOWERDOWN=10
Recv: // ========== Queried registers ==========
Recv: // GCONF:      ffffffff recalibrate=1 faststandstill=1 en_pwm_mode=1 multistep_filt=1 shaft=1(Reverse) diag0_error=1 diag0_otpw=1 diag0_stall=1 diag1_stall=1 diag1_index=1 diag1_onstate=1 diag1_steps_skipped=1 diag0_int_pushpull=1 diag1_poscomp_pushpull=1 small_hysteresis=1 stop_enable=1 direct_mode=1 test_mode=1
Recv: // CHOPCONF:   ffffffff toff=15 hstrt=7 hend=15 fd3=1 disfdcc=1 chm=1 tbl=3 vhighfs=1 vhighchm=1 tpfd=15 MRES=15(0usteps) intpol=1 dedge=1 diss2g=1 diss2vs=1
Recv: // GSTAT:      ffffffff reset=1(reset) drv_err=1(ErrorShutdown!) uv_cp=1(Undervoltage!)
Recv: // DRV_STATUS: ffffffff SG_RESULT=1023 s2vsa=1 s2vsb=1 stealth=1 fsactive=1 CSACTUAL=255 stallGuard=1 ot=1(OvertempError!) otpw=1(OvertempWarning!) s2ga=1(ShortToGND_A!) s2gb=1(ShortToGND_B!) ola=1(OpenLoad_A!) olb=1(OpenLoad_B!) stst=1
Recv: // FACTORY_CONF: ffffffff FACTORY_CONF=31
Recv: // IOIN:       ffffffff REFL_STEP=1 REFR_DIR=1 ENCB_DCEN_CFG4=1 ENCA_DCIN_CFG5=1 DRV_ENN=1 ENC_N_DCO_CFG6=1 SD_MODE=1 SWCOMP_IN=1 VERSION=0xff
Recv: // LOST_STEPS: ffffffff LOST_STEPS=1048575
Recv: // MSCNT:      ffffffff MSCNT=1023
Recv: // MSCURACT:   ffffffff CUR_A=-1 CUR_B=-1
Recv: // OTP_READ:   ffffffff OTP_FCLKTRIM=31 otp_S2_LEVEL=1 otp_BBM=1 otp_TBL=1
Recv: // PWMCONF:    ffffffff PWM_OFS=255 PWM_GRAD=255 pwm_freq=3 pwm_autoscale=1 pwm_autograd=1 freewheel=3 PWM_REG=15 PWM_LIM=15
Recv: // PWM_SCALE:  ffffffff PWM_SCALE_SUM=255 PWM_SCALE_AUTO=-1
Recv: // PWM_AUTO:   ffffffff PWM_OFS_AUTO=255 PWM_GRAD_AUTO=255
Recv: // TSTEP:      ffffffff TSTEP=1048575
Recv: ok

Send: DUMP_TMC stepper=stepper_z
Recv: // ========== Write-only registers ==========
Recv: // TPWMTHRS:   00000271 TPWMTHRS=625
Recv: // COOLCONF:   00000000
Recv: // IHOLD_IRUN: 00060504 IHOLD=4 IRUN=5 IHOLDDELAY=6
Recv: // TPOWERDOWN: 0000000a TPOWERDOWN=10
Recv: // ========== Queried registers ==========
Recv: // GCONF:      ffffffff recalibrate=1 faststandstill=1 en_pwm_mode=1 multistep_filt=1 shaft=1(Reverse) diag0_error=1 diag0_otpw=1 diag0_stall=1 diag1_stall=1 diag1_index=1 diag1_onstate=1 diag1_steps_skipped=1 diag0_int_pushpull=1 diag1_poscomp_pushpull=1 small_hysteresis=1 stop_enable=1 direct_mode=1 test_mode=1
Recv: // CHOPCONF:   ffffffff toff=15 hstrt=7 hend=15 fd3=1 disfdcc=1 chm=1 tbl=3 vhighfs=1 vhighchm=1 tpfd=15 MRES=15(0usteps) intpol=1 dedge=1 diss2g=1 diss2vs=1
Recv: // GSTAT:      ffffffff reset=1(reset) drv_err=1(ErrorShutdown!) uv_cp=1(Undervoltage!)
Recv: // DRV_STATUS: ffffffff SG_RESULT=1023 s2vsa=1 s2vsb=1 stealth=1 fsactive=1 CSACTUAL=255 stallGuard=1 ot=1(OvertempError!) otpw=1(OvertempWarning!) s2ga=1(ShortToGND_A!) s2gb=1(ShortToGND_B!) ola=1(OpenLoad_A!) olb=1(OpenLoad_B!) stst=1
Recv: // FACTORY_CONF: ffffffff FACTORY_CONF=31
Recv: // IOIN:       ffffffff REFL_STEP=1 REFR_DIR=1 ENCB_DCEN_CFG4=1 ENCA_DCIN_CFG5=1 DRV_ENN=1 ENC_N_DCO_CFG6=1 SD_MODE=1 SWCOMP_IN=1 VERSION=0xff
Recv: // LOST_STEPS: ffffffff LOST_STEPS=1048575
Recv: // MSCNT:      ffffffff MSCNT=1023
Recv: // MSCURACT:   ffffffff CUR_A=-1 CUR_B=-1
Recv: // OTP_READ:   ffffffff OTP_FCLKTRIM=31 otp_S2_LEVEL=1 otp_BBM=1 otp_TBL=1
Recv: // PWMCONF:    ffffffff PWM_OFS=255 PWM_GRAD=255 pwm_freq=3 pwm_autoscale=1 pwm_autograd=1 freewheel=3 PWM_REG=15 PWM_LIM=15
Recv: // PWM_SCALE:  ffffffff PWM_SCALE_SUM=255 PWM_SCALE_AUTO=-1
Recv: // PWM_AUTO:   ffffffff PWM_OFS_AUTO=255 PWM_GRAD_AUTO=255
Recv: // TSTEP:      ffffffff TSTEP=1048575
Recv: ok

Send: DUMP_TMC stepper=extruder
Recv: // ========== Write-only registers ==========
Recv: // TPWMTHRS:   00000107 TPWMTHRS=263
Recv: // COOLCONF:   00000000
Recv: // IHOLD_IRUN: 00060604 IHOLD=4 IRUN=6 IHOLDDELAY=6
Recv: // TPOWERDOWN: 0000000a TPOWERDOWN=10
Recv: // ========== Queried registers ==========
Recv: // GCONF:      ffffffff recalibrate=1 faststandstill=1 en_pwm_mode=1 multistep_filt=1 shaft=1(Reverse) diag0_error=1 diag0_otpw=1 diag0_stall=1 diag1_stall=1 diag1_index=1 diag1_onstate=1 diag1_steps_skipped=1 diag0_int_pushpull=1 diag1_poscomp_pushpull=1 small_hysteresis=1 stop_enable=1 direct_mode=1 test_mode=1
Recv: // CHOPCONF:   ffffffff toff=15 hstrt=7 hend=15 fd3=1 disfdcc=1 chm=1 tbl=3 vhighfs=1 vhighchm=1 tpfd=15 MRES=15(0usteps) intpol=1 dedge=1 diss2g=1 diss2vs=1
Recv: // GSTAT:      ffffffff reset=1(reset) drv_err=1(ErrorShutdown!) uv_cp=1(Undervoltage!)
Recv: // DRV_STATUS: ffffffff SG_RESULT=1023 s2vsa=1 s2vsb=1 stealth=1 fsactive=1 CSACTUAL=255 stallGuard=1 ot=1(OvertempError!) otpw=1(OvertempWarning!) s2ga=1(ShortToGND_A!) s2gb=1(ShortToGND_B!) ola=1(OpenLoad_A!) olb=1(OpenLoad_B!) stst=1
Recv: // FACTORY_CONF: ffffffff FACTORY_CONF=31
Recv: // IOIN:       ffffffff REFL_STEP=1 REFR_DIR=1 ENCB_DCEN_CFG4=1 ENCA_DCIN_CFG5=1 DRV_ENN=1 ENC_N_DCO_CFG6=1 SD_MODE=1 SWCOMP_IN=1 VERSION=0xff
Recv: // LOST_STEPS: ffffffff LOST_STEPS=1048575
Recv: // MSCNT:      ffffffff MSCNT=1023
Recv: // MSCURACT:   ffffffff CUR_A=-1 CUR_B=-1
Recv: // OTP_READ:   ffffffff OTP_FCLKTRIM=31 otp_S2_LEVEL=1 otp_BBM=1 otp_TBL=1
Recv: // PWMCONF:    ffffffff PWM_OFS=255 PWM_GRAD=255 pwm_freq=3 pwm_autoscale=1 pwm_autograd=1 freewheel=3 PWM_REG=15 PWM_LIM=15
Recv: // PWM_SCALE:  ffffffff PWM_SCALE_SUM=255 PWM_SCALE_AUTO=-1
Recv: // PWM_AUTO:   ffffffff PWM_OFS_AUTO=255 PWM_GRAD_AUTO=255
Recv: // TSTEP:      ffffffff TSTEP=1048575
Recv: ok
trevor-powdrell commented 5 years ago

I setup the E3 dip with tmc2130 in spi mode. I used SPI3 pins

[tmc2130 stepper_x] cs_pin: PC10 spi_software_sclk_pin: PB3 spi_software_mosi_pin: PB5 spi_software_miso_pin: PB4

[tmc2130 stepper_y] cs_pin: PC11 spi_software_sclk_pin: PB3 spi_software_mosi_pin: PB5 spi_software_miso_pin: PB4

[tmc2130 stepper_z] cs_pin: PC12 spi_software_sclk_pin: PB3 spi_software_mosi_pin: PB5 spi_software_miso_pin: PB4

[tmc2130 extruder] cs_pin: PD2 spi_software_sclk_pin: PB3 spi_software_mosi_pin: PB5 spi_software_miso_pin: PB4

My reference for these pins came from https://github.com/bigtreetech/BIGTREETECH-SKR-E3-DIP-V1.0/blob/master/Hardware/SKR%20E3-DIP-PIN.pdf

r15ch13 commented 5 years ago

That worked! Thank you! 👍