Custom UART Pins for Steppers

Basic Information:

Printer Model:Custom
MCU / Printerboard: STM32F446 / Custom
Host / SBC: RPI 3A+
klippy.log: Not Relevant

Describe your issue:

When configuring UART3 for the STM32F446 the default pins in STM32CubeIDE are PC5/PB10 (RX/TX), with alternatives PC10/PC11. I would like to use UART3 for controlling TMC2209s, but I don’t see any matching pin combinations in src/stm32/serial.c.

Am I correct in thinking that I would need to build klipper with custom options in serial.c?

Current options:

#elif CONFIG_STM32_SERIAL_USART3
  DECL_CONSTANT_STR("RESERVE_PINS_serial", "PB11,PB10");
  #define GPIO_Rx GPIO('B', 11)
  #define GPIO_Tx GPIO('B', 10)
  #define GPIO_AF_MODE 7
  #define USARTx USART3
  #define USARTx_IRQn USART3_IRQn
#elif CONFIG_STM32_SERIAL_USART3_ALT_PD9_PD8
  DECL_CONSTANT_STR("RESERVE_PINS_serial", "PD9,PD8");
  #define GPIO_Rx GPIO('D', 9)
  #define GPIO_Tx GPIO('D', 8)
  #define GPIO_AF_MODE 7
  #define USARTx USART3
  #define USARTx_IRQn USART3_IRQn

Hi @Mandias ,

The UART pin options in menu config are for communicating between the MCU and host, not for TMC drivers.

See below for how to configure the uart pins on a tmc2209 for example.

Can I just add one thing?

The “UART” referred to by TMC is not a traditional UART interface that is built into an MCU (like “UART3”) - communications use TMC defined “Datagrams” that are either 32 or 64 bits in length with syncing and checksum.

The UART signals are generated in Klipper using a bit-banging approach and handle the datagram format (see tmcuart.c in ~/klipper/src).

As @3dcoded indicated, just specify the UART pins as makes sense for your board.

I see, I was over-thinking it. Thanks