I tried your code and have the same issues. In that the motor stalls at certain medium speeds and doesn't seem to regulate current and overheats. The thing is when I use software spi mode with the correct pins, it moves smooth at all speeds and...
Search for JEM. I tried to add that comment to the locations I changed.
Another change I made was in
TMC2130Stepper.cpp
Around line 35
{
// JEM
// SW_SPIClass *SW_SPI_Obj = new SW_SPIClass(pinMOSI, pinMISO, pinSCK);
//...
Yeah, I used the pins that were convienant for the board layout when I switch to software spi.
I will compare your library, and go back to trying hardware spi. I see you do end and begin transaction where one of the timing errors was. Nice...
I thought I had it but still ran into troubles. Ended up using software spi. And the motor acts weird when I have the SPI going to certain pins on teensy 4.0
Works poorly:
MISO -> 9
MOSI -> 12
SCK -> 11
Works well
MISO -> 16
MOSI -> 19
SCK ->...
I ended up still having issues. I was using TMCStepper library, what really helped was changing the library and adding a delay to make reading from the TMC5160 more reliable.
See: https://github.com/teemuatlut/TMCStepper/issues/303
That could of...